W3C验证错误“重复ID”尽管ID是隐藏的 [英] W3C validation error "duplicate ID" although the ID is hidden

查看:79
本文介绍了W3C验证错误“重复ID”尽管ID是隐藏的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站中,我使用CSS3媒体查询查看手机上的不同样式。然后在我的HTML代码中添加一些 div ,以便仅在移动设备中显示与我隐藏的另一个 div 重复的内容。 / p>

在W3C验证中,它是一个错误,带有重复ID。

但ID不重复,因为其中一个是隐藏的。



我该如何解决这个问题?

解决方案

id 属性的值


[...]必须在所有ID中唯一元素的主子树[...]


所以元素在视觉上隐藏并不重要。



使它们唯一,或使用其他钩子,例如一个值。


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?

解决方案

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.

这篇关于W3C验证错误“重复ID”尽管ID是隐藏的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆