Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like an auto line-height?

Tags:

css

I have a box in CSS with fixed dimensions, enough to fit any of my texts. I don't want white space between the end of the text and the bottom box border. How can I fit them into the boxes? Something like expanding the line-height to fit.

like image 802
dstonek Avatar asked Sep 10 '12 23:09

dstonek


People also ask

What is the difference between height and line height?

Height is the vertical measurement of the container, for example, height of a div. Line-height is a CSS property to specify the line height i.e. the distance from the top of the first line of text to the top of the second. It is the space between the lines of two paragraphs.

What would be the default line height?

Desktop browsers (including Firefox) use a default value of roughly 1.2 , depending on the element's font-family . The used value is this unitless <number> multiplied by the element's own font size.

How do you find the height of a line?

For the optimal readability and accessibility, you should go with140 – 180% line height (this is the space around a line of text). This means if your font size is 16pt, your line height should be at least 16 x 1.4 = 22.4pt (140%), or 16 x1. 8= 28.8pt (180%) maximum value.


2 Answers

line-height: normal; 

Is correct.

like image 183
httpete Avatar answered Sep 18 '22 03:09

httpete


Try vertical-align:bottom.

If that doesn't work, you can try line-height: 1em

If that still doesn't do what you want, you'll have to clarify further what you're trying to achieve.

like image 33
Niet the Dark Absol Avatar answered Sep 20 '22 03:09

Niet the Dark Absol