gpt4 book ai didi

html - HTML5 中的行内元素是否允许 block 级元素?

转载 作者:技术小花猫 更新时间:2023-10-29 11:50:49 25 4
gpt4 key购买 nike

举个例子

<a href="#"><h1>Heading</h1></a>在 HTML5 中有效吗?

最佳答案

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

引用:“Block-level” links in HTML5

提示:如果使用此设置 <a>display: block;或者可能会有意想不到的视觉样式结果:Source: Test Case

更新:

“不允许”其他“内联 block ”组合,其中“默认样式可能导致混淆”- explanation is here :

Cases where the default styles are likely to lead to confusion

Certain elements have default stylesor behaviors that make certaincombinations likely to lead toconfusion. Where these have equivalentalternatives without this problem, theconfusing combinations are disallowed.

For example, div elements are renderedas block boxes, and span elements asinline boxes. Putting a block box inan inline box is unnecessarilyconfusing; since either nesting justdiv elements, or nesting just spanelements, or nesting span elementsinside div elements all serve the samepurpose as nesting a div element ina span element, but only the latterinvolves a block box in an inline box,the latter combination is disallowed.

关于html - HTML5 中的行内元素是否允许 block 级元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6061869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com