Skip to main content
HTML Validation

The “name” attribute is never allowed on the “div” element.

About This HTML Issue

The name attribute is not a valid attribute for the <div> element.

The name attribute is only allowed on specific HTML elements that have a defined use for it, such as <input>, <form>, <iframe>, <object>, <map>, <select>, <textarea>, and <meta>. On these elements, name serves a purpose: identifying form data sent to a server, targeting frames, or referencing image maps.

The <div> element does not accept name. If the goal is to identify or reference a <div>, use the id attribute instead. The id attribute is a global attribute, valid on any HTML element, and provides a unique identifier for styling with CSS, targeting with JavaScript, or linking with fragment URLs.

If the name attribute was being used as a hook for document.getElementsByName(), switching to id with document.getElementById() (or using a class with document.querySelectorAll()) is the correct approach.

Invalid example

<div name="sidebar">
  <p>Some content</p>
</div>

Valid example

<div id="sidebar">
  <p>Some content</p>
</div>

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?
🌍 Trusted by teams worldwide

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.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries