H1-H6 font sizes in HTML

前端 未结 11 532

In HTML (and in typography in general, I suppose), there appears to be some defined sizes for H1-H6 -elements.

Ie., if the baseline font size is 16px (or 100%), then h1

11条回答
  •  温柔的废话
    2021-01-29 22:31

    They are defined by each browser maker independently.

    They are not uniform across browsers and are there for semantics (Large header, slightly smaller header etc...).

    If you look at the HTML 4 specification for these, there no mention of how they are supposed to be styled, only that they should be. From the spec:

    Visual browsers usually render more important headings in larger fonts than less important ones.

    If you want these to be consistent, you should use a reset stylesheet that defines them.

    Even though w3 has defined a suggested default stylesheet for HTML 4 with the following details, most browsers ignore this suggestion:

    h1              { font-size: 2em; margin: .67em 0 }
    h2              { font-size: 1.5em; margin: .75em 0 }
    h3              { font-size: 1.17em; margin: .83em 0 }
    h5              { font-size: .83em; margin: 1.5em 0 }
    h6              { font-size: .75em; margin: 1.67em 0 }
    h1, h2, h3, h4,
    h5, h6          { font-weight: bolder }
    

    (yes, I see no font-size: for h4)

提交回复
热议问题