Home > Article > Web Front-end > How to Eliminate Extra Space Below Textareas in Different Browsers?
Extra Space Below Textarea in Browsers
In HTML, textareas can exhibit an extra space at the bottom, which varies in height across different browsers. This gap arises due to the inline or inline-block nature of textareas, as it represents space for potential text descenders.
To remove this extra space, the CSS property "vertical-align: top" should be applied to the textarea element. This property ensures that the textarea's baseline aligns with the top of the surrounding element, effectively eliminating the gap.
The following revised HTML and CSS code demonstrates the solution:
<code class="html"><style> body { margin: 0; padding: 0; } .main { background-color: red; } textarea { background-color: gray; resize: none; margin: 0; border: 0 none; padding: 10px; height: 50px; overflow: hidden; vertical-align: top; } </style></code>
The above is the detailed content of How to Eliminate Extra Space Below Textareas in Different Browsers?. For more information, please follow other related articles on the PHP Chinese website!