HTML <link>
Tag Tutorial
The <link>
tag is used to define a relationship between the current document and an external resource. This tag is commonly used to link to external CSS files, favicon icons, and other resources.
Example:
In the following example, we use the <link>
tag to link an external CSS file to our HTML document:
<link rel="stylesheet" type="text/css" href="styles.css">
Attributes of the <link>
Tag:
Attribute | Description |
---|---|
rel | Specifies the relationship between the current document and the linked resource. Common values include stylesheet , icon , and alternate . |
type | Specifies the MIME type of the linked resource. For CSS files, the value should be text/css . |
href | Specifies the URL of the linked resource. This attribute is required for the <link> tag. |
media | Specifies the media type or media query for which the linked resource is intended. This attribute is optional. |
Full Syntax of the <link>
Tag:
<link rel="value" type="value" href="url" media="value">
By using the <link>
tag, you can easily link external resources, such as CSS files, favicon icons, and more, to your HTML documents. This helps to keep your HTML code clean and organized.