1.行内样式
<p style="color:white;background-color:red">啦啦啦啦啦</p>
2.内嵌样式表
<style type="text/css">
p {
font-weight: bold;
font-style: italic;
color: red;
}
</style>
<body>
<p>洗白白</p>
<p style="color:blue">啦啦啦</p>
</body>
3.引入外部样式表
<link rel = "stylesheet" type = "text/css" href = "a.css"></link>
4.标签选择器
p{ font-size:14px; }
所有p标签都将显示14号字体
5.id选择器
#mytitle{ border:3px dashed green; }
6.类选择器
.one{ width:800px; }
7.后代选择器(有空格)
div p {color: red;}
8.交集选择器(没有空格)
h3h4p {color: red;}
9.并集选择器
p,h1,#mytitle,.one {color: red;}
10.子代选择器
div > p {color: red;}
11.序选择器
ul li:first-child {color: red;}
12.伪类选择器
同一个标签,根据其不同的状态,拥有不同的样式,这就叫做伪类选择器
12.1 静态伪类只能用于超链接的样式
:link 链接点击之前
:visited 链接点击之后
12.2 动态伪类针对所有标签都适用的样式
:hover 悬停:当鼠标放在标签上的时候
:active 激活: 当鼠标点击标签,但不松手
:focus 某个标签获得焦点时