1、E F 包含选择符 选择所有被E元素包含的F元素
例子:
<style type="text/css">
p a{
font-size:20px;
color:red;
}
</style>
<body>
<p><a href="#">你好</a></p>
</body>
2、E>F,子选择符,选择所有作为E元素的子元素F
3、E~F,兄弟选择符,选择所有作为E元素的子元素 F
4、E+F,相邻选择符,选择所有紧贴E元素之后的F元素
5、id和class选择符,id 及 class 均是css 提供由用户自定义标签名称的选择符,用户可以使用选择符id及class 来对页面中的xhtml标签进行自定义名称,从而达到扩展xhtml标签及组合html标签的目的。
6、id 选择器可以为标有特定 id 的 HTML 元素指定特定的样式,以 "#" 来定义。
例1:
<head>
#p1 {
font-size:12px;
font-weight:bold;
}
</head>
<body>
<p id="p1"> 这是一个段落 </p>
</body>
7、在网页中,每个id名称中只能使用一次,不得重复,与id 不同,class 允许重复使用。比如页面中的多个元素,都可以使用同一个样式定义。
class选择器用"."