
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>The style.css file is as follows
h1 {
color: blue;
background-color: yellow;
border: 1px solid black;
}
p {
color: red;
} 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>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> 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!