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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:51:50+00:00 2026-06-11T10:51:50+00:00

So i was examining the css float property when i noticed a strange behavior

  • 0

So i was examining the css float property when i noticed a strange behavior that i couldn’t know its reason.

This is a link to the code and preview of four divs, first two are floated right and left, third and forth just a normal divs.

I do understand that the third div will get overlapped by the second one, however what i don’t understand is why the content of the third div got shifted down, shouldn’t it hide behind the second div?

P.S i know the problem can be fixed using the clear property for the third div, however i am more concerned about the reason behind this behavior.

Code:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
aside, article, section, header, footer, nav {
    display: block;
}
html, body {
    margin: 0;
    padding: 0;
}
html {
    background: #ccc;
}
body {
    width: 600px;
    background: #fff;
    margin: 2em auto 2em;
    font: 100% Arial, Helvetica, sans-serif;
}
div {
    margin-bottom: 1em;
    margin-right: 2em;
    width: 85px;
    height: 50px;
    border: 1px solid #000;
    padding: 25px;
}
/*add styles here*/
.element1 {
    background: rgb(26, 78, 175);
    float:right;
    color:white;
}
.element2 {
    background: rgb(85, 66, 54);
    float:left;
    color:white;
}
.element3 {
    background: rgb(247,120,37);
}
.element4 {
    background: rgb(211, 206, 61);
}

?
</style>
</head>
<body>
    <div class="element1">Element 1 floated right</div>
    <div class="element2">Element 2 floated left</div>
    <div class="element3">Element 3 normal flow</div>
    <div class="element4">Element 4 normal flow</div>
</body>
</html>
  • 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-11T10:51:51+00:00Added an answer on June 11, 2026 at 10:51 am

    I’ve found the answer to my question within this document.

    Quoting from the document:

    Since a float is not in the flow, non-positioned block boxes created before and after the float box flow vertically as if the float didn’t exist. However, line boxes created next to the float are shortened to make room for the floated box. Any content in the current line before a floated box is reflowed in the first available line on the other side of the float.

    So basically what the document says is, floated elements can overlap the Box model of elements added to the document normal flow, however it can’t overlap their content; in other words, content of an overlapped element is restricted to the non-overlapped space.

    P.S. So far i have abstracted the floating behavior as such:

    Element1: floated element

    Element2: non-positioned element

    1-Draw Element2’s box model.

    2-Draw the Element1’s box model and its content.

    3-If Element2 still has non-overlapped space start filling it with its content.

    4-If the space couldn’t hold the whole content, start appending them under Element2 box model.

    Hope this would help.

    Btw, thanks and +1 to everyone who contributed to the question.

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

Sidebar

Related Questions

I am examining a core dump, and noticed that in one frame the 'this'
I've been examining the code of CodeIgniter and CakePHP and I noticed that some
Examining the compiled code of the sinf() on our GCC implementation, I see that
So, examining this directory structure /include_one.php /include_two.php /directory/main_file.php Assume that I am in /directory/main_file.php
For some reason, I'm getting an UnsupportedOpeationException with the following code. Examining it in
Greetings, everyone! Examining my own code, I came up to this interesting line: const
I was examining one of my client's code and came across this. $(document).ready(function() {
I've been examining some PHP code today and I've noticed the usage of do-while
Examining Zend Framework, I found that all setter methods (of those I’ve examined) return
Examining bytecode, I've noticed javac seems to duplicate checkcast instructions when casting to array

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.