I explicitly set the line-height property of an <input> element in CSS. But when I check the element in firebug, the line-height value of this element is not what I set in CSS. And it seems that the line-height value has nothing to do with what I set in CSS. What is the possible reason for this?
I explicitly set the line-height property of an <input> element in CSS. But when
Share
According to the definition of
line-heightin the CSS 2.1 specification, it has a specific meaning for block container elements and a different meaning for non-replaced inline elements. I can’t find any statement on replaced inline elements there, and aninputelement can be regarded as a replaced element, somewhat debatably.Anyway, odd as it may seem, browsers seem to ignore
line-heightoninputelements. As a workaround, you might consider setting theheightproperty, or setting vertical padding. But the results won’t be consistent across browsers. As a rule of thumb, we should expect the rendering of a text input box to the under the control of the browser, though in some cases some features can be tuned using CSS.