I'm not sure about the convention regarding headings in HTML5, but I wanted to know if I could add a <small>
in a <h3>
, like this (this could apply to any tag inside any heading tags):
<h3>Payment details <small>(this is your default card)</small></h3>
HTML <small> Tag.
HTML defines six levels of headings. A heading element implies all the font changes, paragraph breaks before and after, and any white space necessary to render the heading. The heading elements are H1, H2, H3, H4, H5, and H6 with H1 being the highest (or most important) level and H6 the least.
In simple terms: Heading tags are HTML elements used to define the headings of a page. They differentiate the heading <h1> and sub-headings <h2> to <h6> from the rest of the content. The number from 1 to 6 determines the importance and the position a heading has in the overall hierarchy of the heading structure.
h1 is the highest heading level (and, by default, the largest in terms of font size) and h6 the lowest (and smallest).
Yes, that markup validates. You can check it yourself on http://validator.w3.org/
Something to be aware of with HTML5 though is a change to the notion of block-level elements: https://developer.mozilla.org/en/HTML/Block-level_elements
The specs for heading elements:
says that it has phasing content model:
Content model: Phrasing content.
Looking at the part of the specs for phasing content model:
It says this:
Note: Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not any flow content.
Aside from this, you cannot put heading in another heading - this is from W3C validator:
Error Line 1, Column 23: Heading cannot be a child of another heading. <!DOCTYPE html><h1><h2></h2></h1>
Although I could not find in the specs where it explicitly says this, there are restrictions that seem rather specific. This can yield to some very odd behavior such as that the above HTML would actually be parsed as
<h1></h1><h2></h2>
e.g. see this SOq for an example of indirect issues it can cause:
Just in case someone runs into this...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With