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 thesection of the HTML document, use theelement 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:
## of the HTML document # section, use the
element to link the CSS file to HTML.
property with the correct path to the external CSS file.
style.cssand it is located in the
csssubfile of the folder where the HTML file is located folder, the HTML code is as follows:
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!