Home >Web Front-end >CSS Tutorial >How to reference CSS files into html web pages

How to reference CSS files into html web pages

coldplay.xixi
coldplay.xixiOriginal
2021-04-29 10:35:3411209browse

Methods to reference CSS files into HTML web pages: 1. Embed CSS styles directly in HTML tag elements; 2. Use the style built-in style in HTML; 3. Use [@import] to reference external CSS files .

How to reference CSS files into html web pages

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to quote CSS files into html web pages:

1. Embed css styles directly in html tag elements, such as <div style=" font-size:14px; color:#FF0000;">I am div css test content-www.divcss5.com supports<code>

The effect is as shown below

How to reference CSS files into html web pages

2. Insert the style statement code in the head part of the html header as follows:

<style type="text/css"> 
<!-- 
.ceshi {font-size:14px; color:#FF0000;}/*这里是设置CSS的样式内容*/ 
--> 
</style>

The specific method is as follows:

How to reference CSS files into html web pages

3. Use @import to reference external CSS files

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>css引用方法实例-www.divcss5.com测试实例</title> 
<style type="text/css"> 
<!-- 
@import url(wcss.css);/*这里是通过@import引用CSS的样式内容*/ 
--> 
</style> 
</head> 
 
<body> 
<div class="ceshi">我是div css测试内容www.divcss5.com支持</div> 
 
</body> 
</html>

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to reference CSS files into html web pages. 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:Detailed explanation of three CSS3 blur background effects (code examples)Next article:Detailed explanation of three CSS3 blur background effects (code examples)

Related articles

See more