Calling method: 1. In the head part of the document, use the statement ""; 2. In the style Within the tag, use the "@import url("file path")" statement to call.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
There are three ways to introduce CSS styles: inline styles, internal style sheets, and external style sheets. Among them, the external style sheet is a .css file containing css styles.
So how to call external css files in HTML? There are two methods: link type and import type.
Grammar:
1. Link type
<link type="text/css" rel="styleSheet" href="CSS文件路径" />
2. Import type
<style type="text/css"> @import url("css文件路径"); </style>
For example:
<!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>
The difference between link type and import type
1. Belongs to XHTML
2. Loading first CSS file to the page
@import
1. It belongs to CSS2.1
2. Load the HTML structure first and then load the CSS file.
(Learning video sharing: css video tutorial)
The above is the detailed content of How to call css files in HTML. For more information, please follow other related articles on the PHP Chinese website!