CSS学习笔记一
id选择器可以为标有特定 id的HTML元素指定特定的样式 id选择器是以 “#” 来定义的 <!DOCTYPE html> <html> <head> <title>Node</title> <style type="text/css"> #red {color: red;} #green {color: green;} </style> </head> <body> <p id="red">id选择器:red -- 红色</p> <p id="green">id选择器:green -- 绿色</p> </body> </html> id选择器常建立 派生选择器 #sidebar p { font-style: italic; text-align: right; margin-top: 0.5em; } #sidebar p { font-style: italic; text-align: right; margin-top: 0.5em; } #sidebar h2 { font-size: 1em; font-weight: normal; font-style: italic; margin: 0; line-height: 1.5; text-align: right; } 如上,在使用sidebar选择器时,应用在p标签上会使用第一个CSS样式 单独的选择器