How to include css in the webpage
时间: 2024-03-26 18:42:32 浏览: 62
To include CSS in a webpage, you can use one of the following methods:
1. External style sheet: Create a separate CSS file with all the styles for your website and link to it in the head section of your HTML document using the `link` tag. For example:
```
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
```
2. Internal style sheet: Embed CSS styles directly in the head section of your HTML document using the `style` tag. For example:
```
<head>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
</style>
</head>
```
3. Inline styles: Apply styles directly to an HTML element using the `style` attribute. For example:
```
<p style="color: red; font-size: 16px;">This text is red and 16px</p>
```
It is generally recommended to use external style sheets as it allows for more efficient and easier maintenance of your CSS styles across multiple pages.
阅读全文