<link> Tag in HTML

The <link> tag in HTML is used to define the relationship between a document and an external resource. It is most commonly used to link to external style sheets, but it can also be used to link to other resources like icons or prefetching resources.

Key Points on <link> Tag:

Syntax of <link> Tag:

Syntax Example

<link rel="stylesheet" href="styles.css">

Example of <link> Tag in HTML:

This example demonstrates linking to an external CSS file for styling.

Code Example

<head>
            <link rel="stylesheet" href="styles.css">
        </head>

Output

(Output will depend on the linked CSS file and its effects on the HTML document.)

Attributes of <link> Tag:

The <link> tag is essential for linking external resources like CSS files, favicons, and more. It is always used within the <head> element to ensure proper loading before rendering the page. The href attribute should always point to a valid file path, and the rel attribute should define the appropriate relationship.