HTML <link> Element Guide
The <link> tag links external resources to your HTML document. It's a void element (no closing tag) that goes strictly inside the <head> section. Common uses include linking CSS stylesheets, favicons, fonts, and optimizing resource loading.
Required Attributes
The rel attribute specifies the relationship between the document and the linked resource. Common values include: stylesheet for CSS files, icon for favicons, preconnect for DNS prefetching, and preload for resource preloading. The href attribute is mandatory and specifies the URL of the external resource.
Semantic Placement
Always place <link> tags in the <head> section. They should not be placed in the <body>. The browser prioritizes parsing the document head, ensuring essential resources like styles and fonts are fetched immediately.
Common Use Cases
- →Linking CSS stylesheets (
rel="stylesheet") - →Linking favicons for browser tabs (
rel="icon") - →Preconnecting to web font domains (
rel="preconnect")
