2 replies [Last post]
Akrep
Akrep's picture
Offline
newbie
Last seen: 5 years 39 weeks ago
Timezone: GMT+2
Joined: 2014-12-26
Posts: 2
Points: 3

Hello,
Been reading some tutorials about html5 (which also led me to read some css tutorials as well).

Question: What is the shortest way to change background color of a page using CSS?
In older versions of html, adding a:

<body bgcolor="#FFFFFF">

line was all i needed to do. Now I am trying to change the background with putting css code on each element(?) [header, nav, section, aside, footer things]. I am using the following code after enclosing the "head" part of the html. It is the first line of the "body" section but the following code leaves an empty (white) space (about 5px or something) at the top of my page.

 
header {
background-color:#EEEEEE;

How do I get rid of that white space?

Akrep
Akrep's picture
Offline
newbie
Last seen: 5 years 39 weeks ago
Timezone: GMT+2
Joined: 2014-12-26
Posts: 2
Points: 3

Well I handled it with

Well I handled it with adding:

padding-top:8px;

line. Couldn't think of anything else Smile

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 8 hours 43 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9767
Points: 3849

Sounds like you have met margin-collapse

See Meyer on margin collapse.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.