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

  • Home
  • SEARCH
  • 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 431181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:56:57+00:00 2026-05-12T19:56:57+00:00

I have the age-old problem of a div wrapping a two-column layout. My sidebar

  • 0

I have the age-old problem of a div wrapping a two-column layout. My sidebar is floated, so my container div fails to wrap the content and sidebar.

<div id="container">
  <div id="content"></div>
  <div id="sidebar"></div>
</div>

There seem to be numerous methods of fixing the clear bug in Firefox:

  • <br clear="all"/>
  • overflow:auto
  • overflow:hidden

In my situation, the only one that seems to work correctly is the <br clear="all"/> solution, which is a little bit scruffy. overflow:auto gives me nasty scrollbars, and overflow:hidden must surely have side effects.
Also, IE7 apparently shouldn’t suffer from this problem due to its incorrect behaviour, but in my situation it’s suffering the same as Firefox.

Which method currently available to us is the most robust?

  • 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-12T19:56:57+00:00Added an answer on May 12, 2026 at 7:56 pm

    Depending upon the design being produced, each of the below clearfix CSS solutions has its own benefits.

    The clearfix does have useful applications but it has also been used as a hack. Before you use a clearfix perhaps these modern css solutions can be useful:

    • css flexbox
    • css grid

    Modern Clearfix Solutions


    Container with overflow: auto;

    The simplest way to clear floated elements is using the style overflow: auto on the containing element. This solution works in every modern browsers.

    <div style="overflow: auto;">
      <img
        style="float: right;"
        src="path/to/floated-element.png"
        width="500"
        height="500"
      > 
      <p>Your content here…</p>
    </div>
    

    One downside, using certain combinations of margin and padding on the external element can cause scrollbars to appear but this can be solved by placing the margin and padding on another parent containing element.

    Using ‘overflow: hidden’ is also a clearfix solution, but will not have scrollbars, however using hidden will crop any content positioned outside of the containing element.

    Note: The floated element is an img tag in this example, but could be any html element.


    Clearfix Reloaded

    Thierry Koblentz on CSSMojo wrote: The very latest clearfix reloaded. He noted that by dropping support for oldIE, the solution can be simplified to one css statement. Additionally, using display: block (instead of display: table) allows margins to collapse properly when elements with clearfix are siblings.

    .container::after {
      content: "";
      display: block;
      clear: both;
    }
    

    This is the most modern version of the clearfix.


    ⋮

    ⋮

    Older Clearfix Solutions

    The below solutions are not necessary for modern browsers, but may be useful for targeting older browsers.

    Note that these solutions rely upon browser bugs and therefore should be used only if none of the above solutions work for you.

    They are listed roughly in chronological order.


    “Beat That ClearFix”, a clearfix for modern browsers

    Thierry Koblentz’ of CSS Mojo has pointed out that when targeting modern browsers, we can now drop the zoom and ::before property/values and simply use:

    .container::after {
        content: "";
        display: table;
        clear: both;
    }
    

    This solution does not support for IE 6/7 …on purpose!

    Thierry also offers: “A word of caution: if you start a new project from scratch, go for it, but don’t swap this technique with the one you have now, because even though you do not support oldIE, your existing rules prevent collapsing margins.”


    Micro Clearfix

    The most recent and globally adopted clearfix solution, the Micro Clearfix by Nicolas Gallagher.

    Known support: Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+

    .container::before, .container::after {
      content: "";
      display: table;
    }
    .container::after {
      clear: both;
    }
    .container {
      zoom: 1;
    }
    

    Overflow Property

    This basic method is preferred for the usual case, when positioned content will not show outside the bounds of the container.

    http://www.quirksmode.org/css/clearing.html
    – explains how to resolve common issues related to this technique, namely, setting width: 100% on the container.

    .container {
      overflow: hidden;
      display: inline-block;
      display: block;
    }
    

    Rather than using the display property to set “hasLayout” for IE, other properties can be used for triggering “hasLayout” for an element.

    .container {
      overflow: hidden;
      zoom: 1;
      display: block;
    }
    

    Another way to clear floats using the overflow property is to use the underscore hack. IE will apply the values prefixed with the underscore, other browsers will not. The zoom property triggers hasLayout in IE:

    .container {
      overflow: hidden;
      _overflow: visible; /* for IE */
      _zoom: 1; /* for IE */
    }
    

    While this works… it is not ideal to use hacks.


    PIE: Easy Clearing Method

    This older “Easy Clearing” method has the advantage of allowing positioned elements to hang outside the bounds of the container, at the expense of more tricky CSS.

    This solution is quite old, but you can learn all about Easy Clearing on Position Is Everything: http://www.positioniseverything.net/easyclearing.html


    Element using “clear” property

    The quick and dirty solution (with some drawbacks) for when you’re quickly slapping something together:

    <br style="clear: both" /> <!-- So dirty! -->
    

    Drawbacks

    • It’s not responsive and thus may not provide the desired effect if layout styles change based upon media queries. A solution in pure CSS is more ideal.
    • It adds html markup without necessarily adding any semantic value.
    • It requires a inline definition and solution for each instance rather than a class reference to a single solution of a “clearfix” in the css and class references to it in the html.
    • It makes code difficult to work with for others as they may have to write more hacks to work around it.
    • In the future when you need/want to use another clearfix solution, you won’t have to go back and remove every <br style="clear: both" /> tag littered around the markup.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some age-restricted content needed to confirm 18 years old stuff. so I
All, Im having the age old problem with character encoding... I have a mySQL
Age old question! When you have finished developing and testing your ASP.Net web application,
I have a object var foo = { jon : {age: 'old', feeling: 'sad'
I have a variable named age and a function named AGE. Ignore the problem
I've been running into the age-old problem of cross-browser compatibility ever since I began
I'm facing an age old question of html page width - have decided graphics
the age-old problem. I need to position a <footer> Element at the bottom of
I have the following code: age = raw_input(How old are you? ) height =
I have a minimum age custom validator which is straight forward enough: The constraint(Minage.php)

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.