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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:11:55+00:00 2026-06-06T21:11:55+00:00

I wrote a page with flex columns using ‘display:inline-block’ as in this demo ,

  • 0

I wrote a page with flex columns using ‘display:inline-block’ as in this demo, but met a problem with white-spaces and newlines:

Even though .left and .right are both width:50%, but since there are white-spaces and a newline between them, they actually take up more than 100% width and so .right just goes to next line.

<!--demo 1-->
<div class="container">
    <div class="left box">
    </div>
    <div class="right box">
    </div>
</div>

Deleting white-spaces and newlines between .left and .right works, and now they are on the same line, but the HTML is less expressive.

<!--demo 2-->
<div class="container">
    <div class="left box">
    </div><div class="right box">
    </div>
</div>

So, anyway to keep indents?

  • 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-06T21:11:56+00:00Added an answer on June 6, 2026 at 9:11 pm

    Working Fiddle

    Add two classes in CSS:

    .lfloat {
        float: left;
    }
    
    .clrflt {
        clear: both;
    }
    

    Change your HTML code to:

    <!--demo 1-->
    <div class="container">
        <div class="left box lfloat"></div>
        <div class="right box lfloat"></div>
        <div class="clrflt"></div>
    </div>
    

    EDITED

    inline-blocking adds a 4px border (due to which it shifts the div to the next line). Hence, float is a more preferred way.

    You can see this fiddle that uses display:inline-block:

    <html>
        <head>
            <style>
            *{padding:0;margin:0}
            ul#container{width:204px}  //Had to add 4px for extra width
             ul#container li{display:inline-block;height:100px;width:100px;background:#666}
            .left{width:50%}
            .right{width:50%;background:#0ca}
            </style>
        </head>
        <body>
            <ul id="container">
               <li>Left</li>
               <li>Right</li>
            </ul>
        </body>
        </html>
    

    You can read more about these issues at a blog here.

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

Sidebar

Related Questions

This may sound like a SuperUser issue, but I wrote the page in question
I wrote a Delphi function retrieving a web page from another application. This works
I wrote this method to check if a page exists or not: protected bool
Hey I wrote this to grab get a FB page feed and output it
I wrote this small page and for some reason when I cilck on the
I'm facing a wordpress / htaccess problem. This should be really simple, but it's
I wrote a flex application that get the host string from the browser using
I wrote this page to be an image gallery. When you hover over a
I wrote a Java program to download a HTML page. But CPU usage is
Inspired by the top answer on this page I wrote a python program to

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.