How to introduce css

coldplay.xixi
Release: 2023-01-05 16:09:26
Original
6537 people have browsed it

How to introduce css: 1. Add the style to the style attribute of the tag; 2. Add it to the style tag and add it to the head tag; 3. Write the css style in the file with the extension [.css] file, then import the style, and import it inside the head tag.

How to introduce css

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

Methods to introduce css:

1. Inline style (interline style): Add style to the style attribute of the tag:

<!DOCTYPE>
<html>
<head>
  <meta charset="utf-8" />
  <title>行内样式</title>
</head>
<body>
     <!--使用行内样式引入CSS-->
     <h1 style="color:red;">HTML中文网</h1>
     <p style="color:red;font-size:30px;">HTML中文网</p>
</body>
</html>
Copy after login

2 , Embedded style sheet (internal style sheet): Add it in the style tag (add it inside the head tag)

<!DOCTYPE>
<html>
<head>
  <meta charset="utf-8" />
  <title>内部样式表</title>
  <!--使用内部样式表引入CSS-->
  <style type="text/css">
    div{
        background: green;
    }
  </style>
</head>
<body>
     <div>我是DIV</div>
</body>
</html>
Copy after login

3. External style sheet: Write the css style in a file with the extension .css. Then import the style and import it (inside the head tag)

<!DOCTYPE>
<html>
<head>
  <meta charset="utf-8" />
  <title>外部样式表</title>
  <!--链接式:推荐使用-->
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  </style>
</head>
<body>
     <ul>
         <li>HTML</li>
         <li>CSS</li>
        <li>JavaScript</li>
     </ul>
</html>
Copy after login

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to introduce css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!