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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:33:17+00:00 2026-05-13T15:33:17+00:00

I have the following input element (I deliberately omitted attributes which weren’t necessary for

  • 0

I have the following input element (I deliberately omitted attributes which weren’t necessary for the example):

<input type="text" style="display: block; height: 40px; font-size: 14px; line-height: 40px"/>

In Chrome and Internet Explorer (probably Opera too), any text inside the input will be vertically centred. However, Firefox seems to ignore this declaration. Setting it to display: inline-block; instead, or using vertical-align: middle; has no effect in Firefox.

I’ve also tried setting the top & bottom paddings to 13px, and the height to 14px, which (combined with the font-size) will result in an element 40px tall. This works as expected; except any characters with tails (like g, q, j etc) are cut off at the bottom.

I’m looking for a cross-browser solution for vertically aligning text in an input box with a fixed height. The input element will have its own hover and focus styles, so faking the centring by positioning the element itself vertically in a 40px tall space is not really an option.

Cheers

  • 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-13T15:33:18+00:00Added an answer on May 13, 2026 at 3:33 pm

    I’ve also tried setting the top & bottom paddings to 13px, and the height to 14px, which (combined with the font-size) will result in an element 40px tall. This works as expected; except any characters with tails (like g, q, j etc) are cut off at the bottom.

    How about setting only the top padding to 13px (not the bottom one) and setting the height to the remaining space, like this:

    <input type="text" style="display: block; height: 27px; padding-top: 13px; font-size: 14px">

    It works as expected in both Firefox and Chrome; I haven’t access to IE at the moment, but I’m quite confident it works in IE too.

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

Sidebar

Related Questions

All I have the following form input element: <input name=payment_amount type=text id=payment_amount value= disabled>
I have the following text input on a budget calculator form which displays the
I have the following (repeating) html: <tr> <td>Some text</td> <td><a href=#>Click me<a/></td> <td><form><input type=hidden
I have the following input element: <input type=radio> <xsl:attribute name=name> <xsl:value-of select=../../os:Row_ID /> </xsl:attribute>
I have the following input element on the page: Search: <input id=example /> I
I have the following HTML <input type=text name=first expression=firstExpression/> <input type=text name=last expression=secondExpression/> <input
I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
I have the following HTMl: <input id=brandID name=brandID type=hidden value= /> <select id=selectList class=textfield70pc
If I have the following code : <li> <span class=radio_appt> <input id=color1 type=radio name=ctl00$cph1$appointment
On my web site, I have the following code: <input type=image src=images/btn.png alt=Submit border=0

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.