Jump to content

background on body


marcomarco
 Share

Recommended Posts

Hi guys,

i have this question if i write:

body {background-color:blue;height:200px;width:200px}

i see all blue because also html will be blue.

Instead with border it works:

body {border:2px solid black;height:200px;width:200px}

Who can explain me the reason for the background?

Link to comment
Share on other sites

The body height by default is set to content within it. If the html element has no background-color set it takes on the colour of the body. So the body is continues to behave as default, but is hidden by html element background colour, until exposed by adding a styling  such as a border to body as you did, or adding background colour to html element.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...