When the above code is executed in a web browser, it will display a web page with styled content from the external CSS stylesheet.
Explanation
The HTML <link>
tag is used to link to external resources such as CSS stylesheets, favicon icons, and other web resources.
The rel attribute specifies the relationship between the current document and the linked document. For example, the "stylesheet" relationship is used to link to external CSS stylesheets, while the "icon" relationship is used to link to favicon icons.
The type attribute specifies the MIME type of the linked document. For example, the "text/css" MIME type is used to link to external CSS stylesheets.
The href attribute specifies the location of the linked document. It can be a relative or absolute URL.
Use
The HTML <link>
tag is mainly used to link to external CSS stylesheets, but it can also be used to link to other types of resources such as favicon icons, RSS feeds, and JavaScript files.
Important Points
- The HTML
<link>
tag is a self-closing tag.
- The rel attribute is required and should be set to "stylesheet" for linking to external CSS stylesheets.
- The type attribute is optional, but it is recommended to specify the MIME type of the linked document.
- The href attribute is required and should point to the location of the linked document.
Summary
The HTML <link>
tag is used to link to external resources such as CSS stylesheets, favicon icons, and other web resources. It is mainly used to link to external CSS stylesheets, but it can also be used to link to other types of resources. The syntax of the <link>
tag consists of three main attributes: rel, type, and href. The rel attribute specifies the relationship between the current document and the linked document, the type attribute specifies the MIME type of the linked document, and the href attribute specifies the location of the linked document.