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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:16:35+00:00 2026-05-22T03:16:35+00:00

inline-blocks are just so nice to use. Imagine this, I want to centre a

  • 0

inline-blocks are just so nice to use. Imagine this, I want to centre a couple of divs, instead of fiddling around with some margin-auto (which end up actually not working when we want to centre multiple divs), all I have to do give all those divs inline-block and put them in a container div with text-align:center

I mean I’m just giving one example (which I’d just came across) on why inline-blocks just pwn. So inline-block allows us to give paddings and margins to inline elements, and at the same time we do not have to declare an explicit width for those elements. Exactly what is the catch here? I simply can’t believe this is without its cost.

  • 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-22T03:16:36+00:00Added an answer on May 22, 2026 at 3:16 am

    The catch is IE6/7 support on naturally block level elements. it only gets it right first time if inline-block is used on an inline element like a or span BUT..

    This can be worked around luckily (inline-blocks are cool!) by using hasLayout – in short redeclaring the blocks display to be inline once they have had hasLayout triggered on them (which the original inline-block rule does)

    The other catch is that inline-blocks naturally should have whitespace between them like words in a sentence, indeed they do in most browsers but you’ve guessed it not in IE. So when you’re trying to align boxes perfectly side-by-side, as if they were floated you have to allow for this space, but not in IE.

    There are a few ways to control this gap, with word-spacing being arguably the most logical one, but not all browsers agree on this, so the most stable cross-browser way I’ve found is to use margin-right: -4px; this means you can use a second workaround for IE6/7 (as it doesn’t have these gaps) to reset it’s right margin to 0 – oh and whitespace in the HTML can sometimes throw a curveball too.

    Here’s a snippet I tried testing to incorporate the IE fixes with which seems to work well across browser, it also tests for the whitespace in HTML problem (which I can’t reconstruct anyhow.. but was there when I originally tested this code a few weeks ago)

    CSS:

    #wrapper {
       background: #eee;
       width: 200px;
       padding: 1px 0;
    }
    
    .foo, .bar {
       display:inline-block;
       width:98px;
       background: #eee;
       color:white;
       text-align:center;
       font-size: 30px;
       font-family: "trebuchet ms", georgia;
       margin-right: -4px; /* this is the easiest cross-browser fix to zero the whitespace between blocks */
    }
    
    .foo, .bar {
    /* THE IE workarounds, must come after the above rule */
    /* note this is a hack.. the !ie7 part.. 
       you could put this rule set in a conditional 
       or use your favourite method  to feed to LTE IE 7 */
    
       display: inline !ie7;
       margin-right: 0 !ie7;
    }
    
    .foo {border: 1px solid #000;}
    .bar {border: 1px solid #f00;}
    
    p {margin: 0;}
    .wrap {margin: 20px 0;}
    

    HTML

    <div id="wrapper">
    <div class="wrap">
        <p class="foo"> Foo </p>
    
    
        <p class="bar"> Bar </p>
    </div>
    </div> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain why you can’t use inline code blocks within server control declarations
I just want to order some li tags the same way I would do
In CSS, can I line up heights of inline-blocks? I thought by setting margins
Let's assume my ASPX page has no inline C# code blocks. So, I can
my code is something like this //css li{display:inline-block} //html #li margin and width are
Why is the default display style for image inline instead of inline-block? Is there
so i have 4 divs (i actually have many more but this will simplify
I've got a problem with the formatting of inline code blocks within the VS2010
I need to inline some javascript code into the Smarty template files and these
i have this jquery voting script, everything is working fine, it just that the

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.