css2的选择符:
- html选择符(标签选择器)
就是把html标签作为选择符使用
如 p{….} 网页中所有p标签采用此样式
h2{….} 网页中所有h2标签采用此样式 Id选择符
定义: #id名{样式…..}
使用:html标签 id=”id名”>…注意:id选择符只在网页中使用一次.
选择符的优先级:从大到小 [ID选择符]->[class选择符]->[html选择符]->[html属性]
关联选择符(包含选择符)
格式: 选择符1 选择符2 选择符3 …{样式….}
例如: table a{….} /table标签里的a标签才采用此样式/
h1 p{color:red} /只有h1标签中的p标签才采用此样式/组合选择符(选择符组)
格式: 选择符1,选择符2,选择符3 …{样式….}
h3,h4,h5{color:green;} /h3、h4和h5都采用此样式/伪类选(伪元素)择符:
格式: 标签名:伪类名{样式….}a:link {color: #FF0000; text-decoration: none} /* 未访问的链接 */
a:visited {color: #00FF00; text-decoration: none} /* 已访问的链接 */
a:hover {color: #FF00FF; text-decoration: underline} /* 鼠标在链接上 */
a:active {color: #0000FF; text-decoration: underline} /* 激活链接 */