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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:55:51+00:00 2026-05-27T17:55:51+00:00

This page shows two images, each contained inside a separate span displayed as an

  • 0

This page shows two images, each contained inside a separate span displayed as an inline block. To the first image is applied the additional style of “display:block”, which removes the space between the image and the bottom of its green-bordered span (which space is provided for descenders when an element is styled as inline). Contrawise, this space is visible between the second image (still displayed as inline) and the blue border of the second span.

Why does displaying the first image as a block create space between the first image’s span and the element containing the span (orange box)? Is it because when one inline element is contained inside another, the spaces allotted for descenders merge in the manner of vertical margins? Also I am wondering why there is a one-pixel space between the top of the blue span and the orange container.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">

<title>test</title>

<style>

.product_box {
    border: 1px solid green;
    display:inline-block; /* to put products side by side */
}
.product_image {
    display:block;
}
.shop_box { /* contains shop logo, shop URL,  link to view additional items (when not all items are displayed), and all the shop's products */
    text-align:center;
    border:1px solid orange;
}
#stats {
    border:1px solid blue;
    display: inline-block;
}


</style>

</head>

<body>

    <div class="shop_box">
        <span class="product_box">
            <img class="product_image" src="http://i.imgur.com/o2udo.jpg">
        </span>
        <span id="stats">
            <img src="http://i.imgur.com/o2udo.jpg" alt="test">
        </span>
     </div>

</body></html>

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-05-27T17:55:52+00:00Added an answer on May 27, 2026 at 5:55 pm

    Whenever there is any whitespace between two inline elements in HTML, the whitespace in will force a gap between them. This happens to your <span> elements because they are inline-elements. This gap can be removed by removing any whitespace between your two span tags, eg:

    <span class="product_box">
        <img class="product_image" src="http://i.imgur.com/o2udo.jpg">
    </span><span id="stats">
        <img src="http://i.imgur.com/o2udo.jpg" alt="test">
    </span>
    

    If your images are not set to display: block, you can remove the extra vertical-space by setting line-height: 0; on your <span> elements.
    If you are setting your images to display: block, it seems like your best is to use the vertical-align property to align them with each other; try:

    .product_box, #stats { vertical-align: middle; }
    

    It’s usually a good idea to use a CSS Reset when developing, to minimize the effect of these browser-defaults.

    Updated Code:

    HTML:

    <div class="shop_box">
        <span class="product_box">
            <img class="product_image" src="http://i.imgur.com/o2udo.jpg" />
        </span><span id="stats">
            <img src="http://i.imgur.com/o2udo.jpg" alt="test" />
        </span>
    </div>
    

    CSS:

    .product_box, #stats { 
        line-height: 0;
        vertical-align: middle; }
    .product_box {
        border: 1px solid green;
        display:inline-block; /* to put products side by side */
    }
    .product_image {
        display:block;
    }
    .shop_box { /* contains shop logo, shop URL,  link to view additional items (when not all items are displayed), and all the shop's products */
        text-align:center;
        border:1px solid orange;
    }
    #stats {
        border:1px solid blue;
        display: inline-block;
    }
    

    Preview: http://jsfiddle.net/Wexcode/4QNhG/

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

Sidebar

Related Questions

The example on this page only shows Groovy assertions without parentheses. assert a !=
On this page: http://www.arvag.net/old/smsbox.de/ when you hover over Informationen and Über ins, it shows
I have a page that shows statistics for users, this cannot be cached because
Can anyone help me with reversing this PHP page navigation? Current script setting shows
In this tutorial I am reading , Dave Ward creates a page that shows
I have this line below that shows a link to go the next page
Firefox has this nice find-a-text-on-the-page dialog, which is non-modal and shows up at the
In my web page i used a gridview. In this gridview it shows a
If I send this request to a page: http://www.server.com/show.xml?color=red&number=two Can I do something like
I have a two forms on a page. The first one has several quantity

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.