简体   繁体   English

对于已经为HTML的block元素,我们需要display:block吗?

[英]Do we need display:block, for a already HTML block element?

I recently learned, that html elements are groupped as Block and Inline Elements. 我最近了解到,html元素分为“ 块”和“ 内联元素”。 So if p is a block element by default, does it mean this is all crossbrowser standart? 因此,如果p在默认情况下是一个元素,是否意味着这就是所有跨浏览器的标准?

While Coding a Website, Do I Need to specify display:block; 在编码网站时,我是否需要指定display:block; for a p tag? 一个p标签?

No you don't have to,Because p is a block element . 不需要,因为p是一个block元素。

You can't put block elements inside inline elements. 您不能将块元素放入内联元素中。 Formatting. 格式化。 By default, inline elements do not force a new line to begin in the document flow. 默认情况下,内联元素不会强制在文档流中开始新的一行。 Block elements, on the other hand, typically cause a line break to occur (although, as usual, this can be changed using CSS) 另一方面,块元素通常会导致换行(尽管通常可以使用CSS进行更改)

Check this for more information of which all tags are block and inline elements: https://www.w3schools.com/html/html_blocks.asp 请检查此内容以获取有关所有标记均为块和内联元素的更多信息: https : //www.w3schools.com/html/html_blocks.asp

Untill you changed it anyhow , p remains block element. 直到您以任何方式更改它为止,p仍然是块元素。 you dont need to specify. 您不需要指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM