W3School TIY
编辑您的代码:
<!DOCTYPE html> <html> <head> <style> p:first-child i { background:yellow; } </style> </head> <body> <p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p> <p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p> <p><b>注释:</b>对于 IE8 及更早版本的浏览器中的 :first-child,必须声明 <!DOCTYPE>。</p> </body> </html>
查看结果: