【问题标题】:The element button must not appear as a descendant of the a element how to solve it [duplicate]元素按钮不能作为a元素的后代出现如何解决它[重复]
【发布时间】:2020-06-08 16:10:20
【问题描述】:

我尝试验证我的代码,但“元素按钮不能作为 a 元素的后代出现”一直显示,我真的不知道如何解决它,这里是它的外观示例。谢谢

<a href=#boats><button><img src="img/boats.png" alt="Boating"></button></a>

【问题讨论】:

  • 在 HTML5 中锚点不能包含按钮

标签: html css button


【解决方案1】:

<a> 标签内不允许使用某些元素。

查看此 SO 帖子以获取其中的列表:Can I nest a <button> element inside an <a> using HTML5?

【讨论】:

    【解决方案2】:

    您应该只使用buttona 标记之一。您可以使用一些建议 here 在按钮中创建与 href 相同的效果。

    【讨论】:

      猜你喜欢
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-10
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多