本教程操作环境:windows7系统、css3&&html5版、dell g3电脑。
css样式的引入方式共有三种:行内样式、内部样式表、外部样式表。其中,外部样式表就是一个包含css样式的.css文件。
那么在html中怎么调用外部css文件?有两种方式:链接式、导入式。
语法:
1、链接式
<link type="text/css" rel="stylesheet" href="css文件路径" />
2、导入式
<style type="text/css"> @import url("css文件路径");</style>
例如:
<!doctype><html><head> <meta charset="utf-8" /> <title>外部样式表</title> <!--链接式:推荐使用--> <link rel="stylesheet" type="text/css" href="css/style.css" /> <!--导入式--> <style type="text/css"> @import url("css/style.css"); </style></head><body> <ol> <li>1111</li> <li>2222</li> </ol></html>
链接式和导入式的区别
2cdf5bf648cf2f33323966d7f58a7f3f
1、属于xhtml
2、优先加载css文件到页面
@import
1、属于css2.1
2、先加载html结构在加载css文件。
(学习视频分享:css视频教程)
以上就是html怎么调用css文件的详细内容。
