Skip to main content

link-types

Validates link type keywords in the rel attribute on <link>, <a>, <area>, and <form> elements against the WHATWG standard.

This rule checks:

  • Whether the keyword is allowed on the specific element (e.g., bookmark is allowed on <a> but not on <link>)
  • Whether a <link> element inside <body> uses only body-ok keywords
  • Whether the keyword is a dropped, rejected, or non-HTML keyword from the Microformats registry
note

The invalid-attr rule also validates rel attribute values via the type system, but it does not check body-ok context and always permits Microformats keywords. The link-types rule provides body-ok checking and Microformats control with more detailed error messages. Both rules can be used together; their checks are complementary.

❌ Examples of incorrect code for this rule

<!-- "bookmark" is not allowed on <link> -->
<link rel="bookmark" />

<!-- "canonical" is not body-ok, so it's not allowed inside <body> -->
<html>
<head></head>
<body>
<link rel="canonical" href="https://example.com/" />
</body>
</html>

<!-- "stylesheet" is not allowed on <a> -->
<a rel="stylesheet" href="/style.css">link</a>

✅ Examples of correct code for this rule

<link rel="stylesheet" href="/style.css" />
<link rel="canonical" href="https://example.com/" />
<a rel="noopener noreferrer" href="https://example.com/">link</a>
<form rel="nofollow" action="/submit"></form>

Interface

{
"link-types": boolean
}

Validates link type keywords in the rel attribute against the WHATWG standard and optionally the Microformats registry.

Options

{
"link-types": {
"options": {
"allowMicroformats"?: boolean | string[]
}
}
}
PropertyTypeDefault ValueDescription
allowMicroformatsboolean | string[]falseWhether to allow Microformats link type keywords. false allows only WHATWG standard keywords. true allows all registered Microformats keywords. An array of strings allows only the specified keywords.

Default Severity

error

Configuration Example

Default (WHATWG standard only)

{
"rules": {
"link-types": true
}
}

allowMicroformats

type: boolean | string[]

Controls whether Microformats link type keywords are allowed. The Microformats keyword list is based on the microformats.org wiki registered keywords.

Even when Microformats keywords are allowed, element context is still enforced. For example, keywords defined only for <a> are rejected on <link>. Microformats keywords are always rejected on <form> because the Microformats registry does not define form context.

true — Allow all registered Microformats keywords

{
"rules": {
"link-types": {
"options": {
"allowMicroformats": true
}
}
}
}

string[] — Allow only specified keywords

Allows only the specified keywords. You can also specify custom keywords that are not in any registry.

{
"rules": {
"link-types": {
"options": {
"allowMicroformats": ["apple-touch-icon", "mask-icon"]
}
}
}
}