W3School测试:
CSS——16/20
HTML——12/20
JS——11/20
1、id选择器——#表示
类选择器——.表示
//注意:id 属性只能在每个 HTML 文档中出现一次。(就是说id是唯一的咯?****)
#red {color:red;}
<p id="red">这个段落是红色。</p>
//注意:类名的第一个字符不能使用数字!
.center {text-align: center}
<h1 class="center">
This heading will be center-aligned
</h1>
(属性选择器)——[ ]表示
//略
2、外部样式表
浏览器会从文件 mystyle.css 中读到样式声明,并根据它来格式文档。
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
3、多重样式的情况
a、外部样式
h3 {
color: red;
text-align: left;
font-size: 8pt;
}
b、内部样式
h3 {
text-align: right;
font-size: 20pt;
}
结果:继承外部颜色样式,内部右对齐、20pt覆盖外部样式。