英文:
If block elements are not supposed to go in inline elements, how come we put block elements in anchor (<a>) elements?
问题
为什么我们要将块元素嵌套在<a>
标签内,如果<a>
是内联元素,而块元素不应该放在内联元素内部?
我原本期望块元素不会放在<a>
标签内,符合指南。
英文:
Why do we nest block elements inside of <a>
if <a>
is inline and block elements are not supposed to go in inline elements?
I was expecting for block elements to not go in the <a>
tag, per the guidelines.
答案1
得分: 3
【内联】和【块】类别是 HTML 4 中组织大多数 HTML 元素的方式。
15 年前,HTML 5 发布了。它更加细致,不仅仅因为它不再试图以 SGML DTD 的形式表达规则。
【a 元素】的内容模型为:
【透明】,但不能有【交互内容】的后代、
a
元素的后代,或指定了tabindex
属性的后代。
这意味着如果 a
元素的父元素允许作为子元素的元素,例如 div
元素,那么a
元素也允许。
英文:
The %inline and %block categories were how HTML 4 organised most elements in HTML.
15 years ago, HTML 5 was released. It is more nuanced, not least because it no longer tries to express the rules in the form of an SGML DTD.
The a element has a content model of:
> Transparent, but there must be no interactive content descendant, a
element descendant, or descendant with the tabindex
attribute specified.
The means that if the a
element's parent allows a (for example) div
element as a child, then so does the a
element.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论