How to include CSS in the webpage ?
时间: 2023-12-27 14:20:45 浏览: 33
There are three ways to include CSS in a webpage:
1. Inline Style: You can add CSS directly to the HTML element using the `style` attribute. For example:
```
<h1 style="color: red;">Hello World</h1>
```
2. Internal Style Sheet: You can add CSS in the `<head>` section of the HTML page using the `<style>` tag. For example:
```
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
h1 {
color: red;
}
</style>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
```
3. External Style Sheet: You can create a separate CSS file with `.css` extension and link it in the `<head>` section of the HTML page using the `<link>` tag. For example:
```
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
```
In this example, the CSS code is in a separate file called `style.css`.