转
内联样式
<p style ="color:red font-size:12px">这里的文字红色</p>
嵌入式CSS写在文件中
<style type="text/css">
span{
color:red;
}
</style>
外部样式
用link标签将CSS样式文件链接到HTML文件里
<link href="base.css" rel="stylesheet" type="text/css">
CSS名称要用有意义的英文字母
rel="stylesheet" type="text/css"是固定写法
link标签一般在<head>里
三者优先级
嵌入式大于外部式的前提:嵌入式位置在外部式后面(<link href.....>在<style type="text/css">后面)
在相同相同权值的情况下,内联>外部>嵌入(就近原则:离被设置的元素越接近,优先级越高)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>嵌入式css样式</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
span{
color:red;
}
</style>
</head>
<body>
<p>哈哈<span style="color:pink">耶</span>快乐</p>
</body>
</html>
(耶为粉色)