

文章出处:标准之路(http://www.aa25.cn)
以#开头的是ID,只能用于一个对象,优先级高于class如,#layout { height: 300px; background: #99FFcc;}
以.点开头的是class类,可以运用到多个对象,而且ID的
以空开头,即开头没有#或.如:body { margin: 0px; }
一个CSS规则应用于多个选择器或标签,之间用逗号分隔,例:
h1,h2,h3,h4,h5,h6 { color: green; }
p,div,span{ font-size:20px; }
清除标签默认样式的代码
body, ul, li, h1, h2, h3, h4, h5, h6, p, form, dl, dt, dd { margin: 0px; padding: 0px; font-size: 12px; font-weight: normal; }
ul { list-style: none; }
img { border-style: none; }
复合选择器
menu ul li {font-size:20px;}
menu ul li a:hover img { margin: 0px;} /*给menu下ul标签下的li标签下图片设置鼠标滑过的规则*/
给其中一个a标签单独设置背景
a#now{background: url(091033_nav_bgl.gif);}/*只有a标签下ID为now的div背景为091033_nav_bgl.gif*/
<div id=now></div>
加*号和减号
例1:style="height:10px;*height:20px;" 在火狐,IE6,IE8下显示为10像素高度,IE7下为20px
例2:height:10px; height:20px\9; *height:30px; -height:40px;
在火狐下显示10px,IE8下为20px,IE7下为30px,IE6下为40px
加!important,表优先级最高,其它位置的属性都被覆盖
.testClass{ color:blue !important;}
<div class="testClass" style="color:red;"> 测试Css中的Important </div>
//说明:文字还是蓝色,它的优先级最高