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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:58:42+00:00 2026-05-31T23:58:42+00:00

I am trying to vertically align a SPAN element in the middle of a

  • 0

I am trying to vertically align a SPAN element in the middle of a parent element.

This is what I am doing:

enter image description here

I am trying to get both the username and password labels to be vertically aligned (middle) with the input boxes.

This is my HTML code:

<div class="login_field_wrap">
    <span>Username</span>
    <input type="text" autocomplete="off" spellcheck="off" id="username" name="username">
    <div class="clear"></div>
</div>

This is what I have tried:

.clear { clear:both; }
.login_field_wrap span {
float:left; vertical-align:middle; font-size:13px; color:#333; font-weight:bold; }
.login_field_wrap input {
float:right; vertical-align:middle; padding:8px 5px; border:solid 1px #AAA;
margin:0px; width:250px; }

Vertically aligning an image element inside of this wrapping DIV works absolutely fine, well in Chrome anyway, it just won’t align with my SPAN!

Any help would be amazing.

  • 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-31T23:58:43+00:00Added an answer on May 31, 2026 at 11:58 pm

    Vertical aligning via CSS can be tricky, and while CSS3 brings about a slew of goodies to help with that, CSS3 support is lackluster in the current browser market.

    To achieve this effect I set the line-height property of the child element equal to the height of its containing element.

    For example, I would use the following CSS:

    .login_field_wrap { height:30px; /* or whatever is appropriate for your design */
    .login_field_wrap span { height:30px; line-height:30px; }
    .login_field_wrap input { height:30px; line-height:30px; }
    

    The only downside of using line-height to vertically align something is if the text overflows onto a second line, in which case your design will essentially break.

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

Sidebar

Related Questions

I am trying to vertically align to the middle both an image and some
I am trying to make text float in the middle vertically. This means there
I'm trying to get several inline and inline-block components aligned vertically in a div
I'm trying to make a small username and password input box. I would like
I'm trying to align some text of different sizes vertically, however, Firefox displays the
i am trying to vertically align the table present in the panel but i
I have a div element with a background image that I am vertically trying
I am trying to vertically align text in IE7 is proving to be a
I am trying to align labels in a form to go below a text
I'm trying to vertically align a table in my document to the bottom 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.