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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:06:25+00:00 2026-05-31T04:06:25+00:00

I could be the first person to discover this (or at least document it

  • 0

I could be the first person to discover this (or at least document it on the web):

HTML:

<div>Vertically Aligned Text<span></span></div>

CSS:

div
{
    height: 100px; /* or whatever % etc. */
}

div > span
{
    display: inline-block;
    visibility: hidden;
    height: 100%;
    vertical-align: middle;
}

It works because the code increases the line-height to 100% of its container, but I don’t understand why setting vertical-align: middle; on the <span></span> affects the text.

I have not found this solution documented on the web, and it is simpler and more flexible than others that I have found. Plus it should work on all browsers from IE6 onwards (obviously replacing the child selector with something else).

To fit the question requirement, is this the simplest and most flexible solution to an age-old question?

  • 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-31T04:06:26+00:00Added an answer on May 31, 2026 at 4:06 am

    I find using the CSS display attribute table-cell the easiest method.

    See this jsFiddle

    And the CSS:

    div
    {
        height:100px; /* or whatever % etc. */
        border: solid 1px black;
        vertical-align : middle; 
        display : table-cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I could not decide if I should ask this here or
Could someone explain this (strange) behavior? Why is the length in the first example
Yes, I've googled and I could not find the answer to this problem. First
I cannot believe I'm the first person to go through this thought process, so
I can't be the first person to have this problem, I must be missing
I'll be the first person to tell someone that my code design could use
When I first started my iOS project I could use capital letters in core
So in the same way that you could do @items.active.first to get the first
It's my first LINQ TO SQL Project , So definitely my question could be
Please see following examples first, and which one is better? Could you compare some

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.