HTML Guides for resource
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The <link> element defines a relationship between the current document and an external resource. It's most often used in the <head> to load stylesheets, declare icons, specify canonical URLs, or provide metadata. The HTML specification requires that at least one of href, itemprop, property, rel, or resource be present on any <link> element. A bare <link> tag with none of these attributes has no defined purpose and is therefore invalid.
This validation error typically occurs in a few scenarios:
- A
<link>element was added as a placeholder and never completed. - Attributes were accidentally removed or misspelled during editing.
- A templating engine or build tool generated an incomplete
<link>tag. - The
relattribute was omitted when onlyhrefwas technically sufficient, but the developer intended to specify a relationship.
While browsers may silently ignore an empty <link> element, leaving it in your markup creates clutter, signals incomplete code, and violates the HTML standard. Keeping your HTML valid ensures predictable behavior across browsers and assistive technologies.
How to fix it
Check every <link> element in your document and make sure it includes at least one of the required attributes. In practice, most <link> elements should have both rel and href:
rel— specifies the relationship (e.g.,stylesheet,icon,canonical,preconnect).href— provides the URL of the linked resource.itemprop— used for microdata markup.property— used for RDFa or Open Graph metadata.resource— used in RDFa to identify a resource by URI.
If a <link> element has no valid purpose, remove it entirely.
Examples
Invalid: <link> with no required attributes
<linktype="text/css">
The type attribute alone does not satisfy the requirement. The validator will flag this element.
Invalid: <link> with only crossorigin
<linkcrossorigin="anonymous">
crossorigin is not one of the required attributes, so this is still invalid.
Valid: stylesheet with rel and href
<linkrel="stylesheet"href="styles.css">
Valid: favicon with rel and href
<linkrel="icon"href="/favicon.ico"type="image/x-icon">
Valid: preconnect hint
<linkrel="preconnect"href="https://fonts.googleapis.com">
Valid: canonical URL
<linkrel="canonical"href="https://example.com/page">
Valid: Open Graph metadata with property
<linkproperty="og:image"href="https://example.com/image.png">
Valid: microdata with itemprop
<linkitemprop="url"href="https://example.com">
Full document example
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="utf-8">
<title>My Page</title>
<linkrel="stylesheet"href="styles.css">
<linkrel="icon"href="/favicon.ico">
<linkrel="canonical"href="https://example.com/my-page">
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
Each <link> element in this document has both a rel and an href attribute, making them valid and clearly communicating their purpose to browsers and validators.
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries