为什么我们不应该将块元素放入内联元素中 [英] Why should we not place block elements inside inline elements

查看:98
本文介绍了为什么我们不应该将块元素放入内联元素中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



不在块内嵌元素中放置块级元素的原因是什么?

如果我在块元素中放置div元素,它将使HTML无效。 p>

解决方案


如果我将一个div元素放置在一个anchor元素中,它会使我的HTML无效。


HTML5以前不是这样的。


是什么原因是不是将块级元素放入内联元素中?

HTML规范描述哪些元素可能包含其他元素。 流量内容通常可以包含流量内容或短语内容,但即便如此,情况并非总是如此。例如,一个 p 元素是一个块级元素,但它可能只包含Phrasing Content。


If I place a div element inside an anchor element, it invalidates my HTML.

What is the reason of not placing block level elements inside inline elements ?

解决方案

If I place a div element inside an anchor element, it invalidates my HTML.

This is not true as of HTML5.

What is the reason of not placing block level elements inside inline elements?

The HTML specification describes which elements may contain other elements. "Flow content" can often contain "Flow Content", or "Phrasing Content", but even this is not always the case. For example, a p element is a block level element, but it may only contain "Phrasing Content".

这篇关于为什么我们不应该将块元素放入内联元素中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆