Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5, Placeholder, line-height in Webkit

Tags:

html

css

I have an input field:

<input type="text" placeholder="whatever">

with styles:

input {
    margin: 0;
    padding: 0 6px;
    font-size: 19px;
    line-height: 19px;
    height: 36px;
    width: 255px;
}

Problem is the line-height is not taking effect for the placeholder in webkit CHROME. so the text in the input field is aligned in an ugly way. Anyone else seen this and now how to fix it?

Thanks

like image 734
AnApprentice Avatar asked Feb 13 '11 02:02

AnApprentice


People also ask

What is WebKit input placeholder?

Description. The non-standard proprietary ::-webkit-input-placeholder pseudo-element represents the placeholder text of a form element. This allows web developers and theme designers to customize the appearance of placeholder text. This pseudo-class is only supported by WebKit and Blink.

What is the use of line height in CSS?

The line-height CSS property sets the height of a line box. It's commonly used to set the distance between lines of text. On block-level elements, it specifies the minimum height of line boxes within the element.

What is the placeholder pseudo-element used for?

The ::placeholder pseudo-element represents placeholder text in an input field: text that represents the input and provides a hint to the user on how to fill out the form. For example, a date-input field might have the placeholder text YYYY-MM-DD to clarify that numeric dates are to be entered in year-month-day order.


1 Answers

Input placeholders don't seem to like pixel line-height values, but this will vertically centre it in the input:

::-webkit-input-placeholder { line-height: normal; }
like image 136
Matt Born Avatar answered Sep 20 '22 18:09

Matt Born