1. Select the first character in the P tag
p:first-letter{
color:red;
font-size:25px;
}
2. Select the first line in the P tab
p:first-line{
color:red;
font-size:25px;
}
3. Add pseudo-classes before and after P
p:before/after{
Content: "';
Setting Property Styles
}
4. set the style of input when it has focus, can be modified, cannot be modified, and is selected
input:focus/enabled/disabled/cheked{
Background:orange;
}
5. Select the first P label in parent
#parent p:first-of-type{
Set style
}
6. Select the P tag that is the only child (without any sibling tags)
#parent p:only-child{
Set style
}
7. Select the second element of the Div, and the second element is the P element (cannot be selected if it does not meet the requirements)
Div p:nth-child{
}
8. Select the nth P element in a div
Div P:nth-of-type (n) {
}
9. Select the first and last elements, and they are P tags
Div p:first/last-child{
}
CSS3 new feature selector (supplemental)