Ryan Ryan - 2 months ago 10x
CSS Question

How to prevent line-height from adding a margin in the top?

Whenever i use a large

it always adds a margin in the very top of the text which i don't want.

Example: http://jsfiddle.net/EstpJ/1/

i want the text to be sharply lined with the borders and not have any kind of top or bottom margin.

How to fix that?


That's exactly what line-height is, it's a manual way to set the height of a line of text for the purposes of wrapping text and such. The actual visible size is determined by the font-size and to a lesser extend by the font-family. The average line-height for normal text/font is around 1.2em. Anything larger than that will cause visible letterboxing, which is exactly what you are describing. Using a smaller value will cause successive lines to overlap each other.

The only way to fix your exact example is introduce more markup to determine line numbers so that you can style the first/last line differently.