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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:46:27+00:00 2026-05-28T20:46:27+00:00

I have an alignment problem in html/css. I simplified my problem to this: <!DOCTYPE

  • 0

I have an alignment problem in html/css. I simplified my problem to this:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <style>
        span { display: inline-block; height: 50px; }
        span.text { background-color: Yellow;}
        span.left, span.right { background-color: Red;  width: 20px;}
    </style>
</head>
<body>
    <span class="left">x</span>
    <span class="text">Text comes here</span>
    <span class="right">x</span>
</body>
</html>

The output in the browser is as expected:

enter image description here

However, span.left and span.right should not contain any content. They are there for layout purposes only. But when I remove the content (“x”) of both spans like this:

<span class="left"></span>
<span class="text">Text comes here</span>
<span class="right"></span>

The output changes to this:

enter image description here

Why is it doing this? What can I do to solve this?

  • 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-28T20:46:28+00:00Added an answer on May 28, 2026 at 8:46 pm

    Vertical align is problematic, since it is set to the default baseline. Just change it to top:

    span { display: inline-block; height: 50px;vertical-align:top; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem that always occurs when I'm using display: inline-block to display
I have a problem about div position relative alignment. I want the second div
I have a problem with alignment of image and content in a list. Here
I'm having a problem with an image and some text. I have this code:
So I've been struggling on a rather weird problem. I've tried everything from display:inline-block
i have a problem regarding alignment of ad. The ad is coming at top
I have problem with matching the html attributes (in a various html tags) with
i have a problem in setting the labels and alignment of dynamically created radio
Does gcc have memory alignment pragma, akin #pragma vector aligned in Intel compiler? I
I have a question relating to alignment in C/C++. In Determining the alignment of

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.