• # July 18, 2012 at 8:40 pm

    I keep seeing this issue and I am not sure what the problem is. I have an h1 tag, margin:0 padding 0; yet the h1 tag sits 1px below the top of the content which makes it 1px below the box on the left which is bad. Why is it doing that?

    # July 18, 2012 at 8:42 pm

    @cybershot Link? Code?

    # July 18, 2012 at 8:44 pm

    Browsers implement their own styling sometimes. Try using a css reset to see if that solves it.

    # July 18, 2012 at 9:03 pm

    @cybershot Can I get the full code?

    # July 18, 2012 at 9:25 pm

    @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.

    # July 18, 2012 at 9:28 pm

    You can set the h1 line-height to .75 but it seems pointless and would disrupt the overall line-height (below the h1). I agree with Josh about the negative margin but I think it’s one of those details that might bug you but it’s actually quite fine and something no one would notice.

    # July 18, 2012 at 9:33 pm

    Although it’s hard to tell without context, I would agree with @ChristopherBurton; it’s probably not that much of an issue.

    # July 18, 2012 at 9:40 pm

    @joshuanhibbert I don’t think I’ve ever seen a typeface’s cap height adding space like that. From what I’ve seen, the top of the capital glyph will butt itself up against the cap height. Sometimes even go above it (such as the overshoot of an ‘O’). I agree with your initial response that it is due to the browser.

    # July 18, 2012 at 9:47 pm

    @cybershot, I think @joshuanhibbert explained it although I can’t verify it as fact because I’m not that advanced in development or browser rendering. However, I’ve had this issue as well and it seems to happen cross-browser.

    # July 18, 2012 at 9:52 pm

    @cybershot I think the confusion is due to it being considered abnormal behavior, which it is not. Sure, it doesn’t equate to leading in print design, but that is how it is specified (

    Still for each glyph, determine the leading L to add, where L = ‘line-height’ – AD. Half the leading is added above A and the other half below D, giving the glyph and its leading a total height above the baseline of A’ = A + L/2 and a total depth of D’ = D + L/2.

    So in layman’s terms: If there is a positive difference between the capital height of the type, and the line-height, that difference is split in half, of which each half is placed above and below each line of type.

    # July 18, 2012 at 9:52 pm

    edit// wow, this thread saw a lot of action since I started posting. note to self, complete a post before catching some of the ballgame…

    # July 18, 2012 at 9:53 pm

    @cybershot I doubt the line-height looks consistent.

    # July 18, 2012 at 9:55 pm

    @cybershot Totally agree with @ChristopherBurton; decreasing the line-height below that of the font-size is very rarely a good idea as it messes with the vertical rhythm of everything below it.

    # July 18, 2012 at 10:07 pm

    @joshuanhibbert Did you edit the 2nd paragraph?

    If not, I think I misread what you had said.

    # July 18, 2012 at 10:20 pm

    @ChristopherBurton I save a comment before proof reading, and then making slight changes. So you might have caught it in the minute before I have proof read it? I know it’s a strange way to comment, it’s just something I’ve always done.

    @cybershot I have done up a jsFiddle to demonstrate what I am talking about:

    As you can see, the margin-top fix (on the left) doesn’t mess with the baseline like the line-height fix does. Also, each line of type sits in the middle of its line, according to the specifications, despite being totally different to how it is done in print design.

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.