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 8916439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:14:35+00:00 2026-06-15T05:14:35+00:00

I have an outer div element called container and two inner div elements called

  • 0

I have an outer div element called container and two inner div elements called firstDiv and secondDiv

the firstDiv will be floating to the left, while the secondDiv will be floating to the right.

I would like the outer div element to take as much width as possible, which means 100% of the available width.

I would also like the two inner elements to take half space, which means 50% of the container div.

Here is some basic code for this:

<html>
    <head>
    
    <style type="text/css">
        #container{
            width:100%;
            height:100%;
            border-style:solid;
        }
    </style>
    </head>
    
    <body>
        <div id="container">
            <div id="firstDiv"> </div>
            <div id="secondDiv"> </div>
        </div>
    </body>
</html>

Question 1

I was expecting a simple solid border to surround the body element, which it seemed like it did, however I got a scroll bar on the y dimension of my browser. Why did this happen? I said I want 100% of body’s width and height, and it seems like the browser used more than that.

Now I added the following CSS code:

    #firstDiv{
        width:50%;
        height:100%;
        border-style:solid;
        }

Question 2
it seems like the div takes 50% of the "container" div, however the height seems to be more than 100%. Why did this happen? Picture:
enter image description here

I do the same for the second div and include the float properties by having the following CSS code:

    #container{
        width:100%;
        height:100%;
        border-style:solid;
    }
    #firstDiv{
        width:50%;
        height:100%;
        border-style:solid;
        float:left;
        }
    #secondDiv{
        width:45%;
        height:100%;
        border-style:solid;
        float:right;
        }

Question 3
I wanted the two div elements to form a two column page. However again the second div element takes more height than intended like the previous one, and also what’s happening is when I resize the browser, the second div goes under the first one.

enter image description here

Why is this happening and how can I avoid it?

  • 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-15T05:14:36+00:00Added an answer on June 15, 2026 at 5:14 am

    Borders are not counted when calculating the width of an element. They are supplements to the specified width. This explains your slight inconsistencies. There is no 100% airtight solution to this problem as far as I know that will do exactly what you want (close to it, yes, but exactly, no). The most reliable is to use a table, but that isn’t a valid solution for designing a page layout as you already certainly know. Another option is to float right and left but have the width specified as either a slightly lower percentage than 50 (such as 48-48) or have a width specified in px which would allow you to calculate precisely the exact sizes that you need.

    When browsers begin to uniformly implement CSS3, the box-sizing property will be able to solve this problem. box-sizing specifies what to take into account when calculating the size of an element. Applying box-sizing:border-box; will take the border into account, but for the moment this isn’t widely enough implemented across browsers to use reliably in your code.

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

Sidebar

Related Questions

Suppose I have an outer container of unknown fixed width, and an inner element,
I have outer div and inner div. I need to place inner div at
I have an outer div, and inside of that, I have an inner div
I have an outer div that is 800px wide. I have an inner div
I have some javascript code with do while outer loop and switch inner loop,
I have a div and it contains elements like this: <div class='anyClass' style='float:left'> <ul
Possible Duplicate: jQuery bind click ANYTHING but ELEMENT I have this HTML <div id=outer>
I have a layout similar to <div id="outer"> <div id="inner"></div> </div> with a mouse
I have two divs, on the outer div I have given an opacity of
I have a div inside of another div. #outer and #inner . #outer has

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.