内联、内部、外部CSS
内联CSS
- 在HTML的元素中添加样式,例如下方的将h1标签变为蓝色
<h1 style="color: blue">代码介绍</h1>
这种方式在实际编码中并不多见,也不推荐使用!
内部CSS
- 在HTML的代码中的head元素中添加样式
<head>
<style>
h1 {
color: blue;
}
</style>
</head>
<body>
<h1>代码介绍</h1>
</body>
注:如果我们有很多的CSS代码,这种方式也不推荐使用;
外部CSS
- 将CSS放入其他文件中,在HTML去引用他即可
- 首先我们需要创建一个CSS文件,并把样式写入这个文件中

- 接着我们需要从HTML页面中与引用这个CSS文件
<head>
<link rel="stylesheet" href="./style.css" />
</head>
注:在CSS很多的情况下,都会采用这种方式;
相关推荐
-
第18问:MySQL CPU 高了,怎么办?2025-02-24 10:27:18
-
mysql索引类型 normal, unique, full text
mysql索引类型 normal, unique, full text2025-02-24 10:05:05 -
uwsgi+django+nginx 搭建部分总结2025-02-24 10:03:33
-
使用Docker配置Nginx环境部署Nextcloud2025-02-24 10:02:03
-
Nginx安装和怎么使用2025-02-24 10:00:45