要鏈接CSS文件到HTML文檔,需在HTML的
中使用<link>標(biāo)簽,1. 使用<link rel="stylesheet" href="styles.css">將外部CSS文件引入,確保rel屬性為"stylesheet"且href指向正確的CSS文件路徑;2. 將該標(biāo)簽置于內(nèi),如示例所示:在和To link a CSS file to an HTML document, you use the <link>
element inside the section of your HTML file. This tells the browser where to find the stylesheet and how to apply it to your page.

Here’s how to do it properly:
1. Use the <link>
Tag in the
Make sure your CSS file is saved (e.g., styles.css
), then add this line inside the section of your HTML document:

<link rel="stylesheet" href="styles.css">
rel="stylesheet"
specifies the relationship — this file is a stylesheet.href="styles.css"
points to the location of your CSS file. You can use a relative or absolute path.
2. Example HTML Setup
<head>My Page <link rel="stylesheet" href="styles.css">Hello, world!
This is styled with an external CSS file.