CSS:层叠样式表
p {
font-size:12px;
color:red;
font-weight:bold;
}
CSS样式的三种方法
1.内联式:直接写在现有的HTML标签中
2.嵌入式:写在当前的文件中
3.外部式:写在单独的一个文件中
style.css span { color:red; }类型选择器:
这是HTML:
<p>What color do you like?</p>
<div>I like blue.</div>
<p>I prefer red!</p>
这是样式表:
/* All p elements are red */
p {
color: red;
}
/* All div elements are blue */
div {
color: blue;
}
类选择器
这是一些HTML:
<ul>
<li class="first done">Create an HTML document</li>
<li class="second done">Create a CSS style sheet</li>
<li class="third">Link them all together</li>
</ul>
这是一些CSS样式:
/* The element with the class "first" is bolded */
.first {
font-weight: bold;
}
/* All the elements with the class "done" are strike through */
.done {
text-decoration: line-through;
}