tag of the HTML document. Add tag inside
tag."/> tag of the HTML document. Add tag inside tag.">Home >Web Front-end >HTML Tutorial >How to link css files in html
How to link CSS files in HTML
To link CSS files in HTML, you need to use <link> within the
<head> tag ;
Tag:
<code class="html"><head> <link rel="stylesheet" href="style.css"> </head></code>
Where:
rel="stylesheet"
The attribute specifies that the resource type to be linked is a style sheethref="style.css"
The attribute specifies the path of the CSS file to be linked Detailed steps:
style.css
and enter your CSS code. <head>
tag in the HTML document: The <head>
tag of the HTML document contains the text document header information, Such as title and metadata. <link>
tag in the <head>
tag: <link>
tag Used for linking external resources in HTML, such as CSS files. rel
attribute: Set the rel
attribute to "stylesheet"
to indicate that the link points to a style surface. href
property: Set the href
property to the path pointing to the CSS file. The path can be absolute (starting from the root directory) or relative (starting from the current HTML file). Example:
Assuming your CSS file is named style.css
and is located in the same directory as your HTML file, then The HTML code is as follows:
<code class="html"><head> <link rel="stylesheet" href="style.css"> </head></code>
Note:
tag can be placed in
<head> anywhere within the tag.
tag for each file.
The above is the detailed content of How to link css files in html. For more information, please follow other related articles on the PHP Chinese website!