I have the following html code:
<!DOCTYPE html> <html> <head> <style> :first-line { color: red; } :first-child { color: blue; } </style> </head> <body> <p>asdasdasdsad<br>sdfsdfs</p> </body> </html>
Output:
asdasdasdasd <- red
sdfsdfs <- blue.
However, I think the p tag is the first child of the body. first-child is a pseudo-class that has a specificity of 10, and first-line is a pseudo-element that has a specificity of 1. Therefore, both lines should appear as blue text, but I'm apparently mistaken.
Please indicate my mistake. Thank you very much.
html css
Zesen huang
source share