HTML & CSS Interview Question #33

What is the difference between a <link> element and an <a> element?

Forms, Validation, Metadata, Media, Responsive Images & Accessibility Junior Beginner

Quick Interview Answer

The link element describes a relationship between the current document and an external resource or related document, usually from the head. It is commonly used for stylesheets, icons, canonical URLs, and resource hints.

Detailed Explanation

The link element describes a relationship between the current document and an external resource or related document, usually from the head. It is commonly used for stylesheets, icons, canonical URLs, and resource hints.

The anchor element creates a hyperlink that users can activate as part of the page content. It normally belongs in the body and represents navigable content.

Code Example

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

<body>
    <a href="/interview">Interview Preparation</a>
</body>