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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:57:31+00:00 2026-05-25T15:57:31+00:00

When you have a floating element inside a container element you are required to

  • 0

When you have a floating element inside a container element you are required to either set the container to overflow auto or add a clear both after the floated element.

This makes sense as you are clearing the floated elements WITHIN the container.

However when using the clearfix CSS trick you are doing the clear after the container and NOT after the floated elements… I’m confused how this is working as you are now clearing the container and not the floats so it should surely still cause the container to have a dodgy height right? Because if I put the clear both AFTER the container with a physical element it would not work so why does it work with the :after ??

Anyone able to explain this? Thanks

Example:

<div style="border:#000 1px solid;padding:10px;">
    <div style="width:100px;height:100px;background:blue;float:left;"></div>
</div>
<div style="clear:both;"></div>

This would not work work but isn’t that what the clearfix virtually does?

  • 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-25T15:57:32+00:00Added an answer on May 25, 2026 at 3:57 pm

    The CSS :after pseudoelement means “after the element’s content, but still inside an element”, not “after the element itself”. This is why it works.

    The mozilla documentation describes it as follows:
    https://developer.mozilla.org/en-US/docs/Web/CSS/::after

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

Sidebar

Related Questions

Usually when I have floating elements inside a container div, I'll have something like
Its the standard float issue. You have a bunch of floating elements inside a
I have a small floating UIView, viewHover, which acts as a container to 2
Suppose I have an div. Inside this div, I have two divs floating left,
Is it valid to have a div inside of a <td> element? I need
I have a few floating elements like a sidebar that floated besides a content
I have an element with a 70% width, and it is floating beside another
I have many elements (floating href tags) in a div with a set height/width,
I have 3 floating containers of unknown width. The surrounding container has a fixed
I have a floating div that gets displayed, and I want it to be

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.