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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:07:15+00:00 2026-06-14T19:07:15+00:00

I have a div, which contains an image and a span. I would like

  • 0

I have a div, which contains an image and a span. I would like the text in the span to be middle-aligned with the image. Naturally, I made a fiddle for your convenience.

Here is the HTML:

<div id="legend">
    <img src="http://fate.holmes-cj.com/plus.png"/>
    <span> * 5</span>
</div>

Here are some of the things I’ve tried:

  • span {vertical-align:middle;} seems to do nothing.
  • span {vertical-align:top;} aligns the text to the top of the image. You would think that if top works, so would middle.
  • span {vertical-align:20px;} gives me what I want, but it depends upon (and interacts with) the div height, the image height, and the font size.
  • adding display:table-cell has been suggested elsewhere on SO, but seems to do nothing in Chrome.

You can see the problem in context at my Fate Dice Roller. Click on “roll” a few times, and then mouse over the histogram. You get some neat stats on your dice rolls, but the text portion is misaligned.

Am I just out of luck here, or is vertical alignment really supposed to be this messy? I would love a solution that doesn’t have to be tweaked when I change the font size.

  • 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-14T19:07:16+00:00Added an answer on June 14, 2026 at 7:07 pm

    Here you go: http://jsfiddle.net/nYbwf/3/

    Just vertical-align: middle on the image element, that way it will align vertically right in the middle instead of baseline.

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

Sidebar

Related Questions

I have a div which contains a number of images. I would like to
I have a <div> which contains a background image, the <div> sits within a
I have a div which contains 2 elements. First element is a span and
I have a container DIV which contains several block-DIVS. Every block-DIV contains SPAN items
I have a page with a wrapper div which contains a background image and
I have a div with background image which contains 3 colors of the same
I have a div, which contains an article. I mean, it may contain text
I have a div with overflow:hidden which contains image ( .draggable()) that is usually
I have a simple HTML button which contains text and an image: HTML: (Already
I want to create a div which contains an image and text on it.

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.