Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Using height element in CSS?

What's wrong with using the "height" element to make sure the nav div and content div are the same height? I've had a problem with my nav div not being as tall as my content div and everyone has been telling me to do things like "negative content margins" and repeating backgrounds, but when I tested the height (i.e. 700px), everything seemed ok.

No one could really tell me why height is a bad thing.

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    There's nothing wrong in using the "height" property of CSS on your div. Maybe they meant not to use the "height" attribute of the div like so:

    <div height="700">content</div>

    This is not W3C-compliant. However using the CSS property is totally W3C-compliant and valid. Like so:

    <div style="height: 700px;">content</div>

    or:

    <style type="text/css">

    #Nav {

    height: 700px;

    }

    </style>

    ...

    <div id="Nav">content</div>

  • 1 decade ago

    If it works for you, then great, use it. Be sure to test in IE6, IE7 and FireFox. I've tried using it in nested divs and had a lot of issues with vertical positioning between the 2 browsers. It just seemed to be supported differently depending on the browser.

    One thing to be aware of, the div will grow in height if more content is added. You can use max-height for FireFox to force a height, but this isn't supported in IE.

Still have questions? Get your answers by asking now.