Reputation: 81
I have just noticed some wired spacing below a textarea, it is different in every browser. Can someone explain why it is there?
span,
textarea {
border: 1px solid black;
margin: 0;
padding: 0;
}
<textarea></textarea>
<span>test</span>
Upvotes: 4
Views: 968
Reputation: 153
The thing with textarea
in HTML is that the text is aligned right next to the bottom margin. If you wish to have it any other way, read about the vertical-align
attribute in CSS.
You can use:
span,
textarea {
border: 1px solid black;
margin: 0;
padding: 0;
vertical-align: middle;
}
<textarea></textarea>
<span>test</span>
Upvotes: 1
Reputation:
Add vertical-align:
top to textarea
.
The reason for the gap is that textarea is an inline (or inline-block) element, and the gap is the space reserved for descenders in text.
span,
textarea {
border: 1px solid black;
margin: 0;
padding: 0;
}
textarea{
vertical-align:top;
}
<textarea></textarea>
<span>test</span>
Upvotes: 0
Reputation: 114990
Add
vertical-align:bottom
This is because
The baseline of some replaced elements, like
<textarea>
, is not specified by the HTML specification, meaning that their behavior with this keyword may change from one browser to the other.
span,
textarea {
border: 1px solid black;
margin: 0;
padding: 0;
vertical-align: bottom;
}
<textarea></textarea>
<span>test</span>
Upvotes: 8