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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:55:37+00:00 2026-05-19T09:55:37+00:00

This is a very common scenario, I think. I’m relatively (no pun intended) new

  • 0

This is a very common scenario, I think.

I’m relatively (no pun intended) new to CSS and am having an issue with float alignment. I have two divs, one which will hold main content to be floated left and the other for navigation, which should be floated right.

Anyway, here is what happens when I don’t apply any CSS formatting. This is desired behavior; the page will scroll down as expected:
Desired behavior

Here is what happens when I apply float: left or float: right to the respective elements:
Undesired page overflow

They both overflow past the page. I want it to stretch the page so that it scrolls down if it doesn’t fit on one screen area.

A snippet of my HTML:

<body>
<div id="wrapper">
    <div id="header"></div>
    <div id="content">
    <div id="main">
        <p>Lorem ipsum [...snip...]</p>
    </div>
    <div id="secondary">
        <p>Lorem ipsum [...snip...]</p>
    </div>
</div>
<div id="footer">&copy;</div>
</div>
</body>

And the corresponding CSS:

#content {
    padding:10px;
    padding-top: 110px;
    padding-bottom:60px;   /* Height of the footer */
}

#main {
    padding: 10px;
    float: left;
    width:70%;
    text-align:left;
}

#secondary {
    padding: 10px;
    float: right;
    width:20%;
}

Why is it doing this, and how can I fix 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-05-19T09:55:38+00:00Added an answer on May 19, 2026 at 9:55 am

    Clear the floats and you should be OK.

    For example according to your example:

    <body>
    <div id="wrapper">
        <div id="header"></div>
        <div id="content">
        <div id="main">
            <p>Lorem ipsum [...snip...]</p>
        </div>
        <div id="secondary">
            <p>Lorem ipsum [...snip...]</p>
        </div>
    
        <!-- clear -->
        <div style="clear:both;"></div>
    </div>
    <div id="footer">&copy;</div>
    </div>
    </body>
    

    Update: for older IE browsers, the clearing div might need a height defined to give it a “hasLayout” property or else it will ignore this div.
    http://www.satzansatz.de/cssd/onhavinglayout.html

    Generally, people make a class definition that has all this info so you only need to type <div class="clear"></div>

    Here’s an example of robust clearing CSS from http://sonspring.com/journal/clearing-floats

    .clear {
        clear: both;
        display: block;
        overflow: hidden;
        visibility: hidden;
        width: 0;
        height: 0;
    }
    

    There are alternative methods to clear floats in the parent div and removing the extra, structural <div> tag but I personally don’t feel a need to investigate if they are bullet-proof if this solution definitely is.

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

Sidebar

Related Questions

I am new to bash, but this should be a very common scenario. I
This is a very common scenario: displaying images in a ListView which have to
this question is about style, because i think this is a very common problem
Ok, this is an very common scenario in web dev, with a very common
I have what I think is a very common scenario. I have an invoice
This question relates to a very specific and common scenario in which a dictionary
I have this scenario, which I think must be pretty common: class Parameter {
This is a very common but rarely solved topic. I seriously need some help
This is a very common thing in web applications. If I have a user
OK this is a very common problem but mine is a bit different and

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.