元素a不得作为按钮元素的后代出现 [英] The element a must not appear as a descendant of the button element
问题描述
请帮助,
我通过 http://validator.w3.org/验证我的html5模板时。我收到消息元素不能作为按钮元素的后代出现。我无法理解这一点。有人可以帮我解决这个问题吗?
Please help, I am getting error via http://validator.w3.org/ while validating my html5 template. I get the message " The element a must not appear as a descendant of the button element". I can't understand this. Could anyone help me to solve this?
这是我的代码---
<div class="post-response btn-group btn-group-lg">
<a href="#"><button type="button" class="btn btn-default"><i class="fa fa-comment"> 5 Comments</i></button></a>
<a href="#"><button type="button" class="btn btn-default"><i class="fa fa-heart"> 5 Likes</i></button></a>
</div>
推荐答案
错误消息已回答您的疑问已经是
根据HTML5规范文档
The Error Message have Answered Your doubt Already According to HTML5 Spec Documentation
您可以将任何元素嵌套在< a>
中,但以下内容除外:
you can nest any elements inside an <a>
except the following:
< a>
audio>
(如果控件属性存在)
audio>
(if the controls attribute is present)
< button>
< details>
< embed>
< iframe>
< img>
(如果存在usemap属性)
<img>
(if the usemap attribute is present)
< input>
(如果type属性不处于隐藏状态)
<input>
(if the type attribute is not in the hidden state)
< keygen>
< label>
< menu>
(如果type属性处于工具栏状态)
<menu>
(if the type attribute is in the toolbar state)
< object>
(如果usemap属性为现在)
<object>
(if the usemap attribute is present)
< select>
< textarea>
< video>
(如果控件属性存在)
<video>
(if the controls attribute is present)
所以你需要使用一些css来设计一个Button(或者有很多方法)而不是添加 Button
在 a
元素内。
So you need to use some css to design an Button (or there is many Methods) instead of adding Button
inside a
element.
这篇关于元素a不得作为按钮元素的后代出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!