Skip to main content
HTML Validation

Element X is missing required attribute Y.

About This HTML Issue

Required attributes exist because they provide information that is fundamental to the element’s purpose. For example, an <img> element without a src attribute has no image to display, and without an alt attribute, assistive technologies have no fallback text to describe the image. A <link> element without rel gives the browser no way to understand the relationship of the linked resource. When you omit a required attribute, several things can go wrong:

  • Accessibility issues: Screen readers and other assistive technologies depend on specific attributes to convey meaning. A missing alt on <img> leaves visually impaired users without any description of the content.
  • Broken functionality: Some elements simply won’t work without their required attributes. A <form> with an <input> that’s missing a type attribute may still render (browsers default to type="text"), but other elements like <map> without name won’t function as intended.
  • Standards non-compliance: Omitting required attributes produces invalid HTML, which can lead to unpredictable rendering across different browsers.

To fix this issue, identify which attribute is missing from the element flagged by the validator, then add it with an appropriate value. Here are common elements and their required attributes:

Element Required Attribute(s)
<img> src, alt
<link> rel
<script> src (if no inline content)
<input> type (recommended)
<meta> charset, name, or http-equiv (at least one)
<map> name
<bdo> dir
<style> None in HTML5, but type was required in HTML4

Examples

Missing alt attribute on <img>

This is one of the most common validation errors. The alt attribute is required on every <img> element.

Incorrect — missing alt attribute:

<img src="photo.jpg">

Correctalt attribute provided:

<img src="photo.jpg" alt="A sunset over the ocean">

If the image is purely decorative and carries no meaningful content, use an empty alt attribute:

<img src="decorative-border.png" alt="">

Missing rel attribute on <link>

The rel attribute tells the browser what the linked resource is for.

Incorrect — missing rel attribute:

<link href="styles.css">

Correctrel attribute provided:

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

Missing name attribute on <map>

The <map> element requires a name attribute so it can be referenced by an <img> element’s usemap attribute.

Incorrect — missing name attribute:

<map>
  <area shape="rect" coords="0,0,100,100" href="/section" alt="Section">
</map>

Correctname attribute provided:

<map name="navigation">
  <area shape="rect" coords="0,0,100,100" href="/section" alt="Section">
</map>
<img src="nav.png" alt="Site navigation" usemap="#navigation">

Missing dir attribute on <bdo>

The <bdo> (bidirectional override) element exists specifically to override text direction, so the dir attribute is essential.

Incorrect — missing dir attribute:

<p>The word in Arabic is <bdo>مرحبا</bdo>.</p>

Correctdir attribute provided:

<p>The word in Arabic is <bdo dir="rtl">مرحبا</bdo>.</p>

When you encounter this validation error, read the validator message carefully — it will tell you exactly which element and which attribute is missing. Add the attribute with a meaningful value appropriate to your content, and revalidate to confirm the issue is resolved.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your free trial today.