I have read a couple of articles about styling the placeholder of an input field using ::-webkit-input-placeholder
in HTML5. It works perfectly, except for one thing.
If I try to increase the font-size to a value higher than 16px, the text gets "cut" at the bottom. This happens regardless of height and padding of the input itself. Does anyone know a way of avoiding this problem, either using pure CSS or javascript?
I have added a screenshot of two inputfields where the placeholders have an font-size of 20px
Jsfiddle: https://jsfiddle.net/bvwdg86x/
Meanwhile, the browser vendors implemented the
::placeholder
CSS pseudo-element.You can find the current state of browser compatibility on caniuse.com.
Currently (2019-04-29) there are following notes:
Placeholder styles will not resize an input field and will not affect its box model. Add font-size to your input to fix the placeholder from getting cut off.
You also might consider adding placeholder styles for other browsers...
The input and its placeholder must have matching font styles
You have to add 'overflow: visible' to the placeholder in your css to get rid of the cropping.