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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:06:06+00:00 2026-05-26T03:06:06+00:00

I am trying to align labels in a form to go below a text

  • 0

I am trying to align labels in a form to go below a text input box. I have adapted my CSS from here.

It displays perfectly in IE 9, but I am having trouble with firefox, chrome and others.

Here’s what it looks like in IE:

IE

And this is what it looks like in firefox:

enter image description here

It looks much worst in chrome, but I would like to get it working in firefox first.

The main concerns are:

  • The text input should be centered above the labels.
  • The colons should be vertically aligned with the text inputs.
  • The drop-down should be vertically aligned with the text inputs.

Here’s my markup:

<form action="" method="post">

    <label for="time">Time settings</label>

    <div class="description">
        Description goes here
    </div>

    <span><label for="time">Hour</label> <input type="text" id="time" name="time" maxlength="2" size="2"></span>
    <span>:</span>
    <span><label for="time-minute">Minute</label> <input type="text" id="time-minute" name="time-minute" maxlength="2" size="2"></span>
    <span>:</span>
    <span><label for="time-seconds">Seconds</label> <input type="text" id="time-seconds" name="time-seconds" maxlength="2" size="2"></span>

    <span>
        <select id="time-ampm" name="time-ampm">
            <option value="am">AM</option>
            <option value="pm">PM</option>
        </select>
    </span>
    </form>

And here is the CSS style:

<style>
    span{
        display: inline-block;
    }

    span input { 
        display: block; 
        position: relative; 
        top: -3em; 
        text-align: center;
    } 

    span label { 
        display: block; 
        padding-top: 1.5em; 
        text-align: center;
    } 
</style>

I am also using the HTML 4.01 strict doctype.

Here’s the form live in jsfiddle: http://jsfiddle.net/VuShK/

Can anyone give me some pointers as to how to fix this?

Solution:
Thanks to everyone who replied.

Here is my final solution with the text inputs being centered. Thanks to AVD for his help.

<style> 
    span{ 
        display: inline-block; 
        position: relative;
        top: -1em;
        text-align:center;
    } 

    span select input {  
        display: block;  
        position: relative;  
        top: -3em;  
    }  

    span label {  
        display: block;  
        position: relative;  
        top:2.7em; 
        text-align: center; 
    }  
</style> 
  • 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-26T03:06:06+00:00Added an answer on May 26, 2026 at 3:06 am

    Try this,

    <style>
        span{
            display: inline-block;
        }
    
        span select input { 
            display: block; 
            position: relative; 
            top: -3em; 
        } 
        span input { text-align:center;}
        span label { 
            display: block; 
            position: relative; 
            top:3em;
            text-align: center;
        } 
    </style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to align an entire label along with text to the
I have input text's and label tags. I can't figure out the CSS to
I'm trying to simply align a set of text and <input> elements to the
I am trying to align my floating labels with my floating input fields. Of
I'm trying to align a text horizontal and vertically. Using de horizontal axis, I
I am trying to align my bitmap font text in my OpenGL application but
I am trying to align a part of text to the right and the
I am trying to center align my google chart but have been unsuccessful in
I have a jQuery Dialog form and on submit I'm trying to validate the
I am trying to center my labels below my image inside my VGroup. The

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.