问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/21966765/w3c-validation-error-duplicate-id-although-the-id-is-hidden