The id attribute’s value must be unique
The id attribute is used to give an HTML element a unique name. That name has several uses:
- In ID selectors in CSS
- Referencing the element with JavaScript through the
getElementByIdDOM method - Making the element an anchor which can be linked to with a fragment identifier
- Associating a
labelelement with a form control via the for attribute - Specifying which header cell(s) that provide header information for a data cell via the headers attribute
The value of each id attribute must be unique in a document. An easy way to check that your HTML document does not contain multiple occurrences of the same id value is to run it through W3C’s HTML Validator.
This post is a Quick Tip. Background info is available in Quick Tips for web developers and web designers.
- Previous post: Make Safari open targeted links in new tabs instead of new windows
- Next post: Version control with Subversion on Mac OS X
Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.
Subscribe / follow
Sponsors
Authentic Jobs
- UI Designer / Frontend Developer at Cosmic (Santa Cruz, CA, Ca, US)
- Senior Java Developer- eCommerce Practice at arvato Systems North America (New York, NY; San Francisco, CA; Chicago, IL, Il, US)
- Software Engineer at Avant Credit (Chicago, IL, Il, US)
- DevOps Engineer at SHOP SMART LLC (Chicago, IL (River North), Il, US)
DreamHost web hosting
Use the promo code 456BEREASTREET3 to save USD 20 when you sign up for DreamHost

