CSS Selector CSS Selector
Divided into two basic selectors and a combination selector
1. Basic Selector
The basic selector is divided into four tag selectors, ID selector, class selector, wildcard selector
Tag Selector
<p>hello python</p>p{ Background-color:aqua; Color: #99cc99;}
ID Selector
<p id= "P1" >world</p> #p1 { background-color: #99cc99; Font-size:larger; Color:antiquewhite;}
Class Selector
<p class= "P2" >karina</p>.p2{ background-color: #99cc99; Font-size:larger; Color:bisque;}
Wildcard Selector
<p>meimei</p>*{ Background-color:bisque; font-size:25px;;}
2. Combination Selectordescendant selectors are separated by spaces:
<style>.outer p{ color:red;}
Multi-element Selector, matching all p1,div1 tags with (,) Comma separated
</style>.p1,.div1{ color: #99cc99;} <style>
The descendant selector is separated by the > number:
<style>.outer>p{ color:red;} </style>
Adjacent selector---down next to by + sign
<style>.outer+p{ Color:antiquewhite;} </style>
Brother tags are separated by the ~ sign
<style>.outer~p{ Color:aliceblue;} </style>
E,f a multi-element selector that matches all E or F elements, separated by commas between E and F :d iv,p {color: #f00;} E F descendant element selector that matches all f elements that are descendants of the e element, separated by a space between E and F: Li a {font-weight:bold;} e > F child element selectors, matching all e element's child elements F :d IV > P {C Olor: #f00; } E + f adjoins the element selector, matching all sibling elements immediately following the E element F :d IV + p {color: #f00;} E ~ F Ordinary Sibling selectors (separated by dashes) :. DIV1 ~ p{font-size:30px;}
Note: About label nesting
A block-level label can nest block-level labels, or inline tags can be nested
But inline tags cannot nest block-level labels
Exception: P cannot nest any block-level tags
Python--css Selector