Reputation: 538
I made a simple example of textarea on jsfiddle with font-size and line-height.
textarea {
font-size: 20px;
line-height: 4;
height: 260px;
}
<textarea>
A
A
A
</textarea>
1) How does browser calculate the AREA_1 height and the AREA_2 height? Why are they different?
2) How does browser calculate the caret size in the textarea? Why does the caret at the first line is much smaller that at the second line?
Upvotes: 0
Views: 485
Reputation: 78676
It turns out it is a bug on Chromium: Cursor line-height bug on inputs
CSS uses what is known as half-leading to render lines of text. This is determined by working out the difference between the line-height and the font-size, dividing by 2, and then placing the calculated amount of space above and below each line of text. So if you have a font-size of 16px and an effective line-height of 24px, the half-leading would be 4px.
By Joshua Hibbert.
Upvotes: 1
Reputation: 53
1) I think the browser uses equal heights above and below one line. Like so:
-----
A
-----
A
-----
2) In my browser (Firefox) the caret is always the same size.
Upvotes: 0