HTML Rules
Below the list of rules supported by Biome, divided by group. Here’s a legend of the emojis:
- The icon indicates that the rule is part of the recommended rules.
- The icon indicates that the rule provides a code action (fix) that is safe to apply.
- The icon indicates that the rule provides a code action (fix) that is unsafe to apply.
- The icon indicates that the rule has been implemented and scheduled for the next release.
| Rule name | Description | Properties |
|---|---|---|
| noAccessKey | Enforce that the accesskey attribute is not used on any HTML element. | |
| noAriaHiddenOnFocusable | Enforce that aria-hidden=“true” is not set on focusable elements. | |
| noAriaUnsupportedElements | Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | |
| noAutofocus | Enforce that the autofocus attribute is not used on elements. | |
| noDistractingElements | Enforces that no distracting elements are used. | |
| noHeaderScope | The scope prop should be used only on <th> elements. | |
| noInteractiveElementToNoninteractiveRole | Enforce that non-interactive ARIA roles are not assigned to interactive HTML elements. | |
| noLabelWithoutControl | Enforce that a label element or component has a text label and an associated input. | |
| noNoninteractiveElementInteractions | Disallow use event handlers on non-interactive elements. | |
| noNoninteractiveElementToInteractiveRole | Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements. | |
| noNoninteractiveTabindex | Enforce that tabindex is not assigned to non-interactive HTML elements. | |
| noPositiveTabindex | Prevent the usage of positive integers on tabindex attribute. | |
| noRedundantAlt | Enforce img alt prop does not contain the word “image”, “picture”, or “photo”. | |
| noRedundantRoles | Enforce explicit role property is not the same as implicit/default role property on an element. | |
| noStaticElementInteractions | Enforce that static, visible elements (such as <div>) that have click handlers use the valid role attribute. | |
| noSvgWithoutTitle | Enforces the usage of the title element for the svg element. | |
| useAltText | Enforce that all elements that require alternative text have meaningful information to relay back to the end user. | |
| useAnchorContent | Enforce that anchors have content and that the content is accessible to screen readers. | |
| useAriaActivedescendantWithTabindex | Enforce that tabindex is assigned to non-interactive HTML elements with aria-activedescendant. | |
| useAriaPropsForRole | Enforce that elements with ARIA roles must have all required ARIA attributes for that role. | |
| useAriaPropsSupportedByRole | Enforce that ARIA properties are valid for the roles that are supported by the element. | |
| useButtonType | Enforces the usage and validity of the attribute type for the element button | |
| useFocusableInteractive | Elements with an interactive role and interaction handlers must be focusable. | |
| useHeadingContent | Enforce that heading elements (h1, h2, etc.) have content and that the content is | |
| useHtmlLang | Enforce that html element has lang attribute. | |
| useIframeTitle | Enforces the usage of the attribute title for the element iframe. | |
| useKeyWithClickEvents | Enforce elements with a click event handler to also have at least one keyboard event handler. | |
| useKeyWithMouseEvents | Enforce that onmouseover is accompanied by onfocus and onmouseout by onblur. | |
| useMediaCaption | Enforces that audio and video elements must have a track for captions. | |
| useSemanticElements | Enforces using semantic DOM elements over the ARIA role property. | |
| useValidAnchor | Enforce that all anchors are valid, and they are navigable elements. | |
| useValidAriaProps | Ensures that ARIA properties aria-* are all valid. | |
| useValidAriaRole | Elements with ARIA roles must use a valid, non-abstract ARIA role. | |
| useValidAriaValues | Enforce that ARIA state and property values are valid. | |
| useValidAutocomplete | Use valid values for the autocomplete attribute on input elements. | |
| useValidLang | Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country. |
nursery
Section titled “nursery”| Rule name | Description | Properties |
|---|---|---|
| noAmbiguousAnchorText | Disallow ambiguous anchor descriptions. | |
| noDuplicateAttributes | Disallow duplication of attributes. | |
| noExcessiveLinesPerFile | Restrict the number of lines in a file. | |
| noInlineStyles | Disallow the use of inline styles. | |
| noScriptUrl | Disallow javascript: URLs in HTML. | |
| noSyncScripts | Prevent the usage of synchronous scripts. | |
| noUndeclaredClasses | Reports CSS class names in HTML class attributes that are not defined | |
| noVueVIfWithVFor | Disallow using v-if and v-for directives on the same element. | |
| useIframeSandbox | Enforce the ‘sandbox’ attribute for ‘iframe’ elements. | |
| useScopedStyles | Enforce that <style> blocks in Vue SFCs have the scoped attribute and that <style> blocks in Astro components do not have the is:global directive. | |
| useVueConsistentVBindStyle | Enforce a consistent style for v-bind in Vue templates. | |
| useVueConsistentVOnStyle | Enforce a consistent style for v-on in Vue templates. | |
| useVueHyphenatedAttributes | Enforce hyphenated (kebab-case) attribute names in Vue templates. | |
| useVueVForKey | Enforce that elements using v-for also specify a unique key. | |
| useVueValidTemplateRoot | Enforce valid Vue <template> root usage. | |
| useVueValidVBind | Forbids v-bind directives with missing values or invalid modifiers. | |
| useVueValidVCloak | Enforce valid v-cloak Vue directives. | |
| useVueValidVElse | Enforce valid usage of v-else. | |
| useVueValidVElseIf | Enforce valid v-else-if directives. | |
| useVueValidVHtml | Enforce valid v-html directives. | |
| useVueValidVIf | Enforces valid v-if usage for Vue templates. | |
| useVueValidVOn | Enforce valid v-on directives with proper arguments, modifiers, and handlers. | |
| useVueValidVOnce | Enforce valid v-once Vue directives. | |
| useVueValidVPre | Enforce valid v-pre Vue directives. | |
| useVueValidVText | Enforce valid v-text Vue directives. | |
| useVueVapor | Enforce opting in to Vue Vapor mode in <script setup> blocks. |
Recommended rules
Section titled “Recommended rules”- noAccessKey (Severity: error)
- noAriaHiddenOnFocusable (Severity: error)
- noAriaUnsupportedElements (Severity: error)
- noAutofocus (Severity: error)
- noDistractingElements (Severity: error)
- noHeaderScope (Severity: error)
- noInteractiveElementToNoninteractiveRole (Severity: error)
- noLabelWithoutControl (Severity: error)
- noNoninteractiveElementToInteractiveRole (Severity: error)
- noNoninteractiveTabindex (Severity: error)
- noPositiveTabindex (Severity: error)
- noRedundantAlt (Severity: error)
- noRedundantRoles (Severity: error)
- noStaticElementInteractions (Severity: error)
- noSvgWithoutTitle (Severity: error)
- useAltText (Severity: error)
- useAnchorContent (Severity: error)
- useAriaActivedescendantWithTabindex (Severity: error)
- useAriaPropsForRole (Severity: error)
- useAriaPropsSupportedByRole (Severity: error)
- useButtonType (Severity: error)
- useFocusableInteractive (Severity: error)
- useHeadingContent (Severity: error)
- useHtmlLang (Severity: error)
- useIframeTitle (Severity: error)
- useKeyWithClickEvents (Severity: error)
- useKeyWithMouseEvents (Severity: error)
- useMediaCaption (Severity: error)
- useSemanticElements (Severity: error)
- useValidAnchor (Severity: error)
- useValidAriaProps (Severity: error)
- useValidAriaRole (Severity: error)
- useValidAriaValues (Severity: error)
- useValidAutocomplete (Severity: error)
- useValidLang (Severity: error)
Missing a rule? Help us by contributing to the analyzer or create a rule suggestion here.
Copyright (c) 2023-present Biome Developers and Contributors.