Home > Daily Programming > CSS Knowledge > Three ways to add CSS

Three ways to add CSS

autoload
Release: 2021-03-31 11:54:17
Original
6646 people have browsed it

Three ways to add CSS

CSS style is an important part of the front-end web page production, so how to use and introduce CSS style is particularly prominent. This article mainly introduces three ways to use CSS style.

1. Use external styles:

 <head>
    <link rel="stylesheet" href="style.css">
 </head>
Copy after login

The style.css file is as follows

 h1 {        
     color: blue;        
     background-color: yellow;        
     border: 1px solid black;
      }     
 p {        
     color: red;
      }
Copy after login

When filling in the href Is the location of the css file

2. Use internal styles:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<!-- 内部样式 内部脚本-->
 <style>
 h1 {        
     color: blue;        
     background-color: yellow;        
     border: 1px solid black;
      }     
 p {        
     color: red;
      }
 </style>

<p>php.cn</p>

</body>
</html>
Copy after login

3. Use inline styles (Inline style):

<body>
    <h1 style="color: blue;background-color: yellow;border: 1px solid black;">Hello World!</h1>
    <p style="color:red;">Test</p>
</body>
Copy after login

Recommended: "2021 CSS Interview Questions Summary (Latest) "

The above is the detailed content of Three ways to add CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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