The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS what am I missing here? Re: what am I missing here?


@cybershot As far as I can tell, that is expected behavior. CSS centers text vertically, placing space above and below to create the appropriate line-height. You can check this by changing the line-height to a fairly small number (i.e. 12px). The best way to solve it would be to use a negative top margin, as you can’t change just the top part of the line-height on its own (another option being a smaller line-height and larger bottom-margin, but this causes problems with multiple lines).

Keep in mind though: depending on the typeface, and the way each browser renders said typeface, it may be slightly off. The space rendered above and below each line of text is calculated using the metrics of a typeface, and this can vary greatly.