HTML5中的内嵌级元素中是否允许块级元素?

前端之家收集整理的这篇文章主要介绍了HTML5中的内嵌级元素中是否允许块级元素?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
例如

是< a href =“#”>< h1>标题< / h1>< / a&在HTML5中有效吗?

解决方法

是的,你写的是有效的HTML5,但它不是所有的内联元素,我认为它只是< a>它适用于..

参考:“Block-level” links in HTML5

提示:如果使用此选项,请将< a>显示:block;或者可能存在非预期的视觉造型结果:Source: Test Case

更新:

对于“默认样式很可能导致混淆”的其他“内嵌块”组合,“禁止” – explanation is here

@H_403_16@

Cases where the default styles are likely to lead to confusion

Certain elements have default styles
or behaviors that make certain
combinations likely to lead to
confusion. Where these have equivalent
alternatives without this problem,the
confusing combinations are disallowed.

For example,div elements are rendered
as block Boxes,and span elements as
inline Boxes. Putting a block Box in
an inline Box is unnecessarily
confusing; since either nesting just
div elements,or nesting just span
elements,or nesting span elements
inside div elements all serve the same
purpose as nesting a div element in
a span element
,but only the latter
involves a block Box in an inline Box,
the latter combination is disallowed.

原文链接:https://www.f2er.com/html5/169374.html

猜你在找的HTML5相关文章