错误:看到一个开始标记但是已经打开了相同类型的元素 [英] Error: An a start tag seen but an element of the same type was already open
问题描述
我的doctype是 html5 。我正在验证这个HTML:
My doctype is html5. I am validating this HTML:
<a class="article-link-block" href="http://localhost/article/231">
<img src="http://localhost/images/article-image.jpg">
<div class="article-info">
<a class="title" href="http://localhost/article/231">Title of the article</a>
<a class="category" href="http://localhost/category/5">Category</a>
<div class="views">24x</div>
<div class="date">13.3.2013</div>
</div>
</a>
我收到此错误:
Error: An a start tag seen but an element of the same type was already open.
我希望整个 div
成为一个锚标记( article-link-block ),并在其中包含另一个锚标记到类别,用户等和其他div(上面的代码简化为只有文章和类别链接。)
I want the whole div
to be an anchor tag ( article-link-block ) and within it another anchor tags to category, user etc. and other divs (the code above is simplified to only article and category link.)
如何在html验证期间摆脱此错误?
How can I get rid of this error during html validation?
推荐答案
如果你想要这一切都是为了验证您是否需要选择是否需要块级链接或子链接。你不能兼得。来自规范:
If you want it all to validate you're going to have to choose whether you want the block level link, or the child links. You can't have both. From the spec:
内容模型:透明,但必须没有互动内容后代。
Content model: Transparent, but there must be no interactive content descendant.
互动内容是:
a
audio
(如果控件
属性存在)按钮
详细信息
嵌入
iframe
img
(如果usemap
属性存在)输入
(如果类型
属性未处于隐藏状态)keygen
label
object
(如果usemap
属性存在)select
textarea
vid eo
(如果控件
属性存在)
a
audio
(if thecontrols
attribute is present)button
details
embed
iframe
img
(if theusemap
attribute is present)input
(if thetype
attribute is not in the Hidden state)keygen
label
object
(if theusemap
attribute is present)select
textarea
video
(if thecontrols
attribute is present)
所以你的选择是:
- 忽略验证器并保持原样(你没有权利期望所有的浏览器都表现出来在这种情况下以相同的方式)
- 完全选择不同的标记结构
- 将块级别或子链接替换为普通元素和
点击
活动
- Ignore the validator and keep it as it is (you have no right to expect all browsers to behave in the same way in this case)
- Choose a different markup structure altogether
- Replace either the block level or child links with normal elements and
click
events
这篇关于错误:看到一个开始标记但是已经打开了相同类型的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!