W3C validation error “duplicate ID” although the ID is hidden

家住魔仙堡 提交于 2019-12-11 18:14:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!