源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> p:first-child { color:blue; } </style> </head> <body> <p>This is some text.</p> <p>This is some text.</p> <p><b>注意:</b>對於 :first-child 工作於 IE8 以及更早版本的瀏覽器, !DOCTYPE 必須已經聲明.</p> </body> </html>
運行結果