常用的有标签选择器、类选择器、ID选择器等等
首先说主要都有哪些选择器
标签选择器(如:body,div,p,ul,li)
类选择器(如:class="head",class="head_logo")
ID选择器(如:id="name",id="name_txt")
全局选择器(如:*号)
组合选择器(如:.head .head_logo,注意两选择器用空格键分开)
继承选择器(如:div p,注意两选择器用空格键分开)
伪类选择器(如:就是链接样式,a元素的伪类,4种不同的状态:link、visited、active、hover。)
字符串匹配的属性选择符(^ $ *三种,分别对应开始、结尾、包含) 在标签内写入style=" "的方式,应该是CSS的一种引入方式,而不是选择器,因为根本就没有用到选择器。
CSS选择器有以下:
1.元素选择器(又称为类型选择器)
html {color:black;}
h1 {color:blue;}
h2 {color:silver;} 2.类选择器
<h1 class="important"> This heading is very important. </h1>
3.ID选择器
<p id="intro">This is a paragraph of introduction.</p>
4.属性选择器
a[href] {color:red;} 5.后代选择器(又称为包含选择器)
h1 em {color:red;} 6.子元素选择器
h1 > strong {color:red;} 7.相邻兄弟选择器
h1 + p {margin-top:50px;}