The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Need Help Getting BG Color to work for Div

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #33464

    I am working on an assignment for school:
    I cannot get the background-color to show up for the content div. It won’t work when I have the column divs on top of it.

    Both the CSS and XHTML validated.

    Any ideas why the background color won’t show up?


    This is because you haven’t cleared your floats.

    Essentially, the content div only contains items which are floated. Floated items are taken out of the regular flow of the document, thus not giving the content div any height (in other words, the content div doesn’t think it is containing anything).

    This is perfectly fine and a tough concept for beginners to wrap their head around. Here’s a great article by Chris:

    The easiest solution for you is adding overflow: hidden; to your div#content.

    Another solution would be to add a “clearing div” just before you #content div closes. HTML:



    .clear { clear: both; }

    Aaa, thank you! It’s starting to make a lot more sense now :D.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.