Home >Web Front-end >HTML Tutorial >How to link external css in html
By connecting external CSS files, style information can be separated from the HTML document, thereby improving code reusability and maintainability. Specific steps include: creating an external CSS file and writing CSS styles; in the
section of the HTML document, use the element to link the CSS file to HTML, and ensure that the value of the href attribute is correct for the external CSS file path.
How to use HTML to link external CSS
Linking external CSS is to use HTML to separate style information from the HTML document common techniques. Doing so improves code reusability and maintainability.
Create an external CSS file:
.css
Text file with extension. Link the CSS file to HTML:
<head>## of the HTML document # section, use the
element to link the CSS file to HTML.
<code class="html"><head> <link rel="stylesheet" href="path/to/style.css"> </head></code>
property with the correct path to the external CSS file.
style.css and it is located in the
css subfile of the folder where the HTML file is located folder, the HTML code is as follows:
<code class="html"><head> <link rel="stylesheet" href="css/style.css"> </head></code>Note:
The above is the detailed content of How to link external css in html. For more information, please follow other related articles on the PHP Chinese website!