0

As shown, the height of the body is only 44 pixels.

44px_height_body

I then set the body's background-color.

chrome_developer_toolkit

As a result, the background color of the entire web page, even the parts outside of the body area, is changed. Why does this happen?

the_page_view

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
sofa
  • 43
  • 4
  • The background defined for `` is applied to the whole page unless you set an explicit background for ``. – AlexP Apr 16 '17 at 08:03

2 Answers2

2

Body tag is used or applied for whole page not the any single line or specific items..

But if you want to change the some height of the page which are different from the <body> tag then...

you can create the <div> tag and set it to the height of 44px and set the color of this div as you wanted to color...

And placed inside the <body> tag. Now its the different color from the tag...

V.Deep
  • 427
  • 2
  • 12
1

The <body> tag in HTML is the entire webpage, not just a 44-pixel strip at the top. When you change the background-color of a webpage, the background of the entire page will change. There was probably just a glitch in the developer tools in your first screenshot that showed the <body> as such a small area.

From w3schools:

The <body> element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc.

anon
  • 154
  • 9
  • The two white boxes appear to be absolutely positioned. If the body element isn't relatively positioned, then the boxes don't contribute to the body element's height and the body may well be empty. No idea why it's 44 pixels tall specifically, though. But it's probably not a glitch. The body element may represent the content of an HTML document, but we're in CSS territory here, not HTML. – BoltClock Apr 16 '17 at 09:21