views:

154

answers:

5

Container/Wrapper Div does not contain all content (ie all the child Div's).I've tried overflow: hidden but still doesn't work. Can someone please tell me why this is happening and what are the possible solutions.

Thank you in advance ;-)

for some reason the whole code does not display??

<html>
<head>  
<style type="text/css">

#wrapper {

margin:0 auto;
width: 600px;
background: yellow; 
}

</style>
</head>
<body>
    <div id="wrapper"> 
<div="header">
<h1>my beautiful site</h1>
</div>


<div id="navigation">
    <ul>
            <li><a href="#">Home </li>
                <li><a href="#">About</li>
                <li><a href="#">Services</li>
                <li><a href="#">Contact us </li>
        </ul>


</div>




<div id ="content">

    <h2> subheading<h2>
        <p>  long paragraph </p>
        </div>

    <div id ="footer">
        copyright 123
        </div>



</div> 
</body>
</html> 
+1  A: 

With my crystal ball, I will predict that your child divs are floated and your container is not. In this case, the container will not expand to fit its contents. Try floating your container and see what happens.

The crystal must have been dusty... However, the code you posted is not valid - you have content inside the head tag and a div outside the html tag. Is this how your page really looks, or is it just an error pasting the code into your question? Try cleaning up the code structure and see if it helps.

EDIT: Found the problem - it is a typo. You have <div="header"> - it should be <div id="header"> (note the missing 'id')

Ray
i couldnt post all the code on there for some reason! yes a few typos opps :-(
Imran
please try again - with the small code fragment you have left, no one will be able to help
Ray
I edited my answer to show the typo in your code that is causing the problem.
Ray
THANK YOU SOO MUCH RAY!!! ;-) IT WORKS!!!!! CAN'T BELIEVE IT'S A TYPO i thought i neeeded a CSS hack
Imran
+1  A: 

Try giving the clear:both to the parent div or put a div at the end of it:

<style type="text/css">
 .clear{clear:both;}
</style>

Possibility One:

<div id="parent">
  <div id="child1">Some Content</div>
  <div id="child2">Some Content</div>
  <div id="child3">Some Content</div>

  <div class="clear"></div>
</div>

Possibility Two:

<div id="parent" class="clear">
  <div id="child1">Some Content</div>
  <div id="child2">Some Content</div>
  <div id="child3">Some Content</div>
</div>
Sarfraz
The second possibility is not the same as the first. If you put the `<div class="clear"></div>` before the `#parent` div then yes, both have the same effect.
ANeves
A: 

You have a DIV in your HEAD element.

Superstringcheese
+1  A: 
<h2> subheading<h2>

You miss a /

Nicolas Viennot
+1  A: 

A great tool: http://validator.w3.org/ - this will tell you if there is markup errors and on what lines.

Moak
thanks Moak i'll try it!
Imran