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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:21:20+00:00 2026-06-13T19:21:20+00:00

Say I have this HTML: ​<div class = block1>hi</div> <div class = block2>hi</div> And

  • 0

Say I have this HTML:

​<div class = "block1">hi</div>
<div class = "block2">hi</div>

And this CSS:

​.block1 {
    width:100px;
    border:1px solid;
    float: left;
}

​.block2 {
    width:100px;
    border:1px solid;
}

Why does block2 need to have float:left; in order to be to the right of block1? Isn’t the property of block1 (float:left) enough?

JsFiddle

  • 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-13T19:21:22+00:00Added an answer on June 13, 2026 at 7:21 pm

    block2 is displayed as a block level element by default, which means it takes up a whole line.

    It doesn’t necessarily have to have float:left to show up on the right of block1; if it is displayed as an inline level element through display:inline, or display:inline-block, it will appear next to its sibling.

    http://jsfiddle.net/8GF4B/1/

    To explain it in further detail, let us imagine you had set float:left on block2 instead:

    .block1 {
        width:100px;
        border:1px solid;
    }
    
    ​.block2 {
        width:100px;
        border:1px solid;
        float: left;
    }
    

    The first thing that will happen is that block2 will be positioned where it would normally be positioned. Let’s find out where.

    • block1 is displayed as a block level element
    • block level elements are rendered as though they had a line break both before and after the element
    • block2 will therefore by default show up on the second line

    Now block2 is taken out of the normal flow, and shifted as far left as it can possibly be … but it is already against the left edge! This results in block2 showing up underneath block1.

    Have a look here for a good explanation of the distinction between inline and block-level elements: https://developer.mozilla.org/en-US/docs/HTML/Block-level_elements

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

Sidebar

Related Questions

Okay so say I have a form element like this: HTML: <div class=form-item> <label>Current
Say I have the following HTML: <head> <style> #container { border: 1px red solid;
Let's say I have this HTML: <textarea>blah</textarea> <br> <div class=select_this>hello!</div> How can I select
Say I have jquery code like this: html += '<div class=index>' + item.index +
Say I have this HTML fragment <td width=25% style=text-align:right; > <span style=font-family: Arial; font-size:
let's say I have this set of HTML-markup and CSS #CSS .inputhelp_text { background:
Say I have several inline-block div tags, like this <div class=image> </div> <div class=image>
So let's say I have the following in 'foo.css': .border { border : solid
I have this html code: <div class=rotation> <ul> <li><img src=... alt= /></li> <li><img src=...
Hi guys lets say I have the following html: <div class=owner> <div> <a href=javascript:void(0)

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.