Beb Pratza Ballus
Beb Pratza Ballus

Reputation: 221

W3C validation error "duplicate ID" although the ID is hidden

In my website I use CSS3 media queries for different styles on mobile. Then in my HTML code I add some div to show only in mobile device that duplicate another div that I hide.

In W3C validation it is an error, with "Duplicate ID".

But the ID not is duplicate because one of this is hidden.

How can I resolve this problem?

Upvotes: 1

Views: 1886

Answers (1)

unor
unor

Reputation: 96697

The id attribute‘s value

[…] must be unique amongst all the IDs in the element's home subtree […]

So it doesn’t matter if the element is visually hidden.

Make them unique, or use some other hook, e.g. a class value.

Upvotes: 2

Related Questions