html - 将 h3 嵌套在 anchor 中 - 这如何有效?

标签 html w3c w3c-validation

<li class="vcard">
  <a class="url" href="/about/us/">
    <img class="photo" alt="some" src="/img/nicething.png">
    <h3>hello</h3>
  </a>
  <p class="role meta">Something here</p>
</li>

我看过这段代码,我已经过验证,它在 w3c HTML5 验证中返回 VALID。

我很难在 anchor 中使用 h3

如果我们 display:block; anchor ,这似乎变得有效?

最佳答案

如果您查看 HTML5 spec , 在 <a> 上有一节标签:

The a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links).

我在 HTML4 spec 中找不到任何内容那是说将 block 级标签放在行内级标签内是无效的,但我确实记得在某处读过它。

关于html - 将 h3 嵌套在 anchor 中 - 这如何有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12659766/

相关文章:

html - 使用 AngularJS 指令进行 W3C 验证

html - 无法摆脱图像之间的空间和边距

html - 有没有办法为特定的 YUI DataTable 实例设置 CSS 信息?

XML Schema 类型别名?

logging - 使用Firebase托管时可以访问w3c样式日志吗

xhtml - 如何在 xHTML 中验证 noscript+meta refresh 标签?

php - 表中滚动条的 2 个问题

html - 在 IE html 上加载 swf

html - 为什么没有 dt 标签的 dl 标签会生效

html - Safari 和 Firefox 无法正确显示网站,但 Chrome 运行良好