Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is body element a block-level or in-line element?

Tags:

html

I've looked on the MDN for any indication whether the HTML body element is a block-level or inline-level element:

Inline Elements / Block-level Elements

Neither of these mentions anything about the body element except:

Block-level elements may appear only within a < body > element.


2 Answers

HTML4 classified elements into the "block-level" and "inline" categories.

However, HTML5 doesn't have that notion. Instead, it was moved to CSS: block-level elements and block boxes and inline-level elements and inline boxes.

According to HTML5, the body element belongs to the sectioning root category. And that's all.

However, in Rendering - The page, HTML5 specifies that body should be displayed as a block by default:

html, body { display: block; }

Then, according the the definition in CSS, it will be block-level, unless you override that style.

like image 102
Oriol Avatar answered Oct 23 '25 20:10

Oriol


W3 defined it as a block. http://www.w3.org/TR/html401/struct/global.html#edef-BODY

It is displayed as a block by default. http://www.w3.org/TR/html-markup/body.html

like image 20
MattTannahill Avatar answered Oct 23 '25 20:10

MattTannahill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!