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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:49+00:00 2026-05-22T21:26:49+00:00

I am having a little trouble understanding the following: test.html <!DOCTYPE html> <html dir=ltr

  • 0

I am having a little trouble understanding the following:

test.html

<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>CSS Test</title>
<link rel="stylesheet" type="text/css" media="all" href="test.css" />
</head>
<body>
    <div id="id_main">
        <div id="id_item1" class="item">
            <p>Item 1</p>
        </div>
        <div id="id_item2" class="item">
            <p>
                Item 2 - This item has more text than the first item
                and it shows because the text wraps around and changes
                the vertical size of the item.
            </p>
        </div>
        <div id="id_item3" class="item">
            <p>Item 3</p>
        </div>
        <div id="id_item4" class="item">
            <p>Item 4</p>
        </div>
        <div id="id_item5" class="item">
            <p>Item 5</p>
        </div>
        </div>
</body>
</html>

test.css

#id_main {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
    background-color: teal;
    vertical-align: top;
}

div.item {
    border: 1px solid black;
    display: inline-block;
    width: 255px;
    text-align: center;
    background-color: grey;
    height: 129px;
}

Since the items all have uniform widths and heights, I was expecting that the items would display in a grid almost like a table. In the first row, though, item1 is aligned with the bottom of the row and item2 is aligned with the top! And the row is larger than the height of either item. Why does this happen?

Thanks,

Carl

  • 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-22T21:26:49+00:00Added an answer on May 22, 2026 at 9:26 pm

    You need to add vertical-align: top to div.item:

    http://jsfiddle.net/DZzc5/2/

    div.item {
        border: 1px solid black;
        display: inline-block;
        vertical-align: top;
        width: 255px;
        text-align: center;
        background-color: grey;
        height: 129px;
    }
    

    To understand why this is required, I recommend you read this:

    http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

    Specifically, the part talking about “the baseline”.

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

Sidebar

Related Questions

I'm having a little trouble understanding how I would use covariance and contravariance in
I'm having a little trouble in understanding how I can read and return the
I'm having a little bit of trouble understanding what the problem is here. I
I am having a little trouble understanding ServiceKnownType in WCF. Taken from this blog
I'm having some a little trouble understanding how to handle the database end of
I am having a little trouble understanding migrations in Ruby on Rails. I have
Im having a little trouble understanding how I should work with xml files, so
I'm learning more about Scala, and I'm having a little trouble understanding the example
having a little trouble with a mapping for the following table setup currently: Shop
I'm having a little trouble understanding how to accomplish what I'm wanting to do

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.