css代码插入形式:内联式、嵌入式、外部式
优先级:内联式>嵌入式>外部式 //ps:嵌入式大于外部式必须嵌入式css样式位置在外部式之后
总结:就近原则
内联式:将代码直接写在现有的HTML标签中
例如:
<p style="color:blue;font-size:12px"> The words are red,and its size is 12px.</p>
嵌入式:将代码卸载<style></style>之间,并且一般情况下嵌入式css样式卸载<head></head>之间
例如:
<style type="tex/css">
span{
color:red;
}
</style>
外部式:将代码写入一个单独的文件中,该文件以“.css”为拓展名,在<head>内(不是在<style>内)使用<link>标签将css样式文件链接到HTML文件内
例如:
<link href="base.css" rel="stylesheet" type="text/css">
注意:
1、css样式文件名称以有意义的英文字母命名,如 main.css。
2、rel="stylesheet" type="text/css" 是固定写法不可修改。
3、<link>标签位置一般写在<head>标签之内。