源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> p { color:blue; text-align:center; } .marked { background-color:red; } .marked p { color:white; } p.marked{ text-decoration:underline; } </style> </head> <body> <p>這個段落是藍色文本,居中對齊。</p> <div class="marked"> <p>這個段落不是藍色文本。</p> </div> <p>所有 class="marked"元素內的 p 元素指定一個樣式,但有不同的文本顏色。</p> <p class="marked">帶下劃線的 p 段落。</p> </body> </html>
運行結果