Reputation: 381
When testing my html code in the W3 validator
, I was given this error and warning message:
Line 21, Column 23: The first occurrence of ID menuItem
was here.
<li id="menuItem"><a href="#visit">Ten Places to Visit</a></li>
✉ Line 29, Column 25: Duplicate ID menuItem.
<li id="menuItem"><a href="#Wrigley">Wrigley Field</a></li>
However, when I try removing the id=""
part of the tag, so it reads <li menuItem>
I lose the attributes of menuItem
.
Should this type of error from the validator typically be ignored, or am I not correcting it properly?
Upvotes: 1
Views: 4757
Reputation: 185
From your code, the W3 Validator is right to have complained! You cannot use the same ID name twice, if you do use it twice, you will ebd up overwriting the other item. W3 validator always track for all these to maintain website standard and integrity. Therefore, you will need to use unique ID name identifier for each reference. Try this:
<li id="menuItem"><a href="#visit">Ten Places to Visit</a></li>
<li id="menuItemA"><a href="#Wrigley">Wrigley Field</a></li>
I hope this helps.
Upvotes: 0
Reputation: 884
The ID menuitem has repeated on the same page. So change make the ID as unique.
In W3 validator ID should be unique.
You can change the code like this.
<li id="menuItem0"><a href="#visit">Ten Places to Visit</a></li>
<li id="menuItem1"><a href="#Wrigley">Wrigley Field</a></li>
Upvotes: 0
Reputation: 26969
Using same id multiple times is not valid. Try to use class
instead of id
(If you are using id to call only style)
Upvotes: 2