Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:37:55+00:00 2026-06-18T10:37:55+00:00

Given the following #container { border:solid 3px red; } #left { float: left; background-color:

  • 0

Given the following

#container {
    border:solid 3px red;
}

#left {
    float: left;
    background-color: lightblue;
    height: 300px;
}

#right {
    float: left;
    background-color: coral;
    height: 300px;
}
<div id='container'>
    <div id='left'>Left content</div>
    <div id='right'>Right content</div>
</div>

(See: http://jsfiddle.net/ericjohannsen/JCPEH/1/)

Why does container apparently not have any area (that is, it has a zero height, plus the border)? I naively expected it to be as tall as the child divs that it contains.

What is the proper way to set this up so that the div containing the two children is as tall as the children?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:37:56+00:00Added an answer on June 18, 2026 at 10:37 am

    You need to clear your floats. You can do this via a clearfix class:

    .clearfix:before,
    .clearfix:after {
        content: " "; 
        display: table; 
    }
    
    .clearfix:after {
        clear: both;
    }
    
    .clearfix {
        *zoom: 1;
    }
    
    #container {
        border:solid 3px red;
    }
    
    #left {
        float: left;
        background-color: lightblue;
        height: 300px;
    }
    
    #right {
        float: left;
        background-color: coral;
        height: 300px;
    }
    <div id='container' class="clearfix">
        <div id='left'>Left content</div>
        <div id='right'>Right content</div>
    </div>

    or a clearing element:

    .clear {
      clear:both;
    }
    
    #container {
        border:solid 3px red;
    }
    
    #left {
        float: left;
        background-color: lightblue;
        height: 300px;
    }
    
    #right {
        float: left;
        background-color: coral;
        height: 300px;
    }
    <div id='container'>
        <div id='left'>Left content</div>
        <div id='right'>Right content</div>
        <div class="clear"><!-- --></div>
    </div>

    Updated Fiddle:
    http://jsfiddle.net/JCPEH/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following HTML: <body><div class=container></div></body> and CSS: body { background-color: #e9f9e9; } .container
Given the following HTML: <!DOCTYPE html> <html> <body> <div id=container> <div id=left style=float: left;
I have the following div : <div id=query style=width:500px; height:200px;border:1px solid black spellcheck=false contenteditable=true></div>​
Given the following registrations builder.Register<A>().As<I>(); builder.Register<B>().As<I>(); builder.Register<C>().As<I>(); var container = builder.Build(); I am looking
Given the following XML, <Container> <Set > <RecommendedCoverSong>Hurt by NiN - Johnny Cash</RecommendedCoverSong> <RecommendedOriginalSong>She
Given the following Code. [TestMethod] public void CanResolveILoggerTest() { var Container = new Castle.Windsor.WindsorContainer();
Given the following code <div class=container> <p>Some Text</p> <p><img src=image.jpg><p> <p>More Text</p> </div> CSS
Newbie question. Given the following html. <div id=mycontainer1 class=container> <input type=text class=name/> <input type=text
Given the following example: container = [ (1, a) , (40, b) , (24,
Given the following classes: public class Container { private List<SomeData> list; // public getter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.