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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:25:43+00:00 2026-06-14T21:25:43+00:00

Live page here . Given this HTML page: section[role=main] { margin: 1em; width: 95%;

  • 0

Live page here.

Given this HTML page:

section[role=main] {
  margin: 1em;
  width: 95%;
  border: 1px solid #999;
}

section[role=main] article {
  width: 40%;
  height: 180px;
  margin: 1em;
  display: inline-block;
  border: 1px solid black;
}
<section role="main">
  <article>Java</article>
  <article></article>
</section>

<section role="main">
  <article>Java</article>
  <article>JavaScript</article>
</section>

I expect both of my articles to be aligned, but as it can be seen in the screenshot below, only when both of my articles have text the <article> elements are center aligned:

alignment issue

Any ideas what is causing this behavior and how can it be fixed?

  • 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-14T21:25:44+00:00Added an answer on June 14, 2026 at 9:25 pm

    This is the consequence of the “baseline” vertical alignment in CSS. From the CSS 2.1 spec, section 10.8 Line height calculations: the ‘line-height’ and ‘vertical-align’ properties

    baseline

    Align the baseline of the box with the baseline of the parent box. If the box
    does not have a baseline, align the bottom margin edge with the parent’s baseline.
    (my emphasis)

    Because the default alignment for the inline-blocks is “baseline”, unless it is overridden, this rule applies. When text is put in the inline-block, that text will create a baseline for the inline-block and the first (non-bolded) sentence applies.

    When there is no text in the inline-block, then it has no baseline and so the second (bolded) sentence applies.

    In the JSFiddle here: http://jsfiddle.net/WjCb9/1/ I have removed from your example the margin:1em which was creating (at least for me) a misleading illusion, and added the text baseline to show where the baseline of the containing box is. The baseline is along the bottom of the word “baseline”, so you can see that the empty inline-block has its bottom margin edge aligned with the parent’s baseline as required by the CSS rule above.

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

Sidebar

Related Questions

Here is the live page I am trying to implement on my Drupal website:
I have four divs in my html page something like this: the working fiddle
I have an ASP.NET MVC Page with a button called Start Live Meeting. When
I am loading content into a page with ajax that will have live click
Live site. Ideally, between border-top and border-bottom, I'd like to have 3 portfolio thumbnails,
Live streaming video in html 5 - what is required from server to stream
so live docs says this for calling .lenght() on an XML object For XML
I've copied some text nodes from the page (i.e., live DOM) and have stored
Using JQuery, I am loading a div from an external HTML page into fancybox
I'm using the Swap Image plugin , particularly Disjoint Rollovers 2. Here's the live

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.