" statement to call; 2. In the style tag, use "@import url ("file path")" statement."/> " statement to call; 2. In the style tag, use "@import url ("file path")" statement.">

Home  >  Article  >  Web Front-end  >  How to call css files in HTML

How to call css files in HTML

青灯夜游
青灯夜游Original
2021-04-26 12:02:404428browse

Calling method: 1. In the head part of the document, use the statement "48181c0ad86b7b4833d043856d8db365"; 2. In the style Within the tag, use the "@import url("file path")" statement to call.

How to call css files in HTML

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

2cdf5bf648cf2f33323966d7f58a7f3f

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does html do?Next article:What does html do?