1、CSS 指层叠样式表 (Cascading Style Sheets)
2、设置标题h1~h6为绿色。
h1,h2,h3,h4,h5,h6
{
color: green;
}
3、列表中的strong元素变为斜体。
li strong
{
font-style: italic;
font-weight: normal;
}
4、id选择器。(id为red内的p元素和h2元素都得到了特殊处理)
#red
p {color:red;}#red h2
{font-size: 1em;font-weight: normal;}#green
{color:green;}
<pid="red"
>这个段落是红色。</p> <pid="green"
>这个段落是绿色。</p>
5、类选择器(类名为center的表格单元文本都为居中对齐)
.center
td {text-align: center}
6、属性选择器
[title]
{border:5px solid blue;}//只要带有title属性的元素都有蓝色的边框
[title=W3School]
{border:5px solid blue;}//带有title属性,且值为W3School的元素都有蓝色的边框
[title~=hello]
{ color:red; }//title属性包含值是hello的元素字体都为红色
[lang|=en] { color:red; }//带有包含指定值en的 lang 属性的所有元素设置样式(字体为红色)