菜鸟学堂
在线运行
源代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟学堂(edu.jb51.net)</title> <style> p:first-child { background-color:yellow; } </style> </head> <body> <p>This paragraph is the first child of its parent (body).</p> <h1>Welcome to My Homepage</h1> <p>This paragraph is not the first child of its parent.</p> <div> <p>This paragraph is the first child of its parent (div).</p> <p>This paragraph is not the first child of its parent.</p> </div> <p><b>注意:</b> :first-child作用于 IE8以及更早版本的浏览器, DOCTYPE必须已经声明.</p> </body> </html>
运行结果
在线运行
菜鸟学堂 edu.jb51.net