h1 h2 h3 h4 h5 h6
HTML5 h1, h2, h3, h4, h5, h6 elements
The h1, h2, h3, h4, h5, h6 elements allows you to add headings to your document: »video
- h1 has rank 1 → the highest rank in page; is the most important heading
- h2 has rank 2 → less important than h1 but more important than h3
- h3 has rank 3 → less important than h2 but more important than h4
- h4 has rank 4 → less important than h3 but more important than h5
- h5 has rank 5 → less important than h4 but more important than h6
- h6 has rank 6 → the lowest rank in page; is the less important heading
About h1, h2, h3, h4, h5, h6 elements
- are optional elements
- multiple h1...h6 elements allowed per HTML5 document
Display & support h1, h2, h3, h4, h5, h6 elements
- display in browser »video
- display type: block





* Operav12.02 display not ok for h1 → h6 elements nested inside elements part of sectioning content
Parents, children h1, h2, h3, h4, h5, h6 elements
- h1, h2, h3, h4, h5, h6 nested within elements »h1...h6 parents
- elements nested within h1, h2, h3, h4, h5, h6 »h1...h6 children
»examples
Attributes h1, h2, h3, h4, h5, h6
- required: none
- optional: global attributes, event attributes
Warning
elements, contribute to document outline: presented - (HTML4 old way)example, (HTML5 new way)exampleSyntax h1, h2, h3, h4, h5, h6
1 2 3 4 5 6 | <> ... </> <> ... </> <> ... </> <> ... </> <> ... </> <> ... </> »video |
Attributes and Values h1, h2, h3, h4, h5, h6 (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | <accesskey="h"> ... </ > | |
2. | class | = | class name | »html »img | <class="class_name"> ... </ > | |
3. | contenteditable | = | "", , true, false | »html | <contenteditable="true"> ... </ > | |
4. | contextmenu | = | menu id value | »html | <contextmenu="menu_id_value"> ... </ > | |
5. | data-* | = | value | - | <data-http-error="404"> ... </ > | |
6. | dir | = | ltr, rtl, auto | »html | <dir="ltr"> ... </ > | |
7. | draggable | = | true, , false | »img | <draggable="false"> ... </ > | |
8. | dropzone | = | copy, move, link, string:, file: | - | <dropzone="copy"> ... </ > | |
9. | hidden | = | "", , hidden | »html »img | <hidden="hidden"> ... </ > | |
10. | id | = | id name | »html »img | <id="unique_id_name"> ... </ > | |
11. | itemid | = | URL | - | - | |
12. | itemprop | = | string | »link »a | - | |
13. | itemref | = | string | - | - | |
14. | itemscope | = | "", , itemscope | - | - | |
15. | itemtype | = | absolute URL | - | - | |
16. | lang | = | language code | »html »head»title »img | <lang="en"> ... </ > | |
17. | spellcheck | = | "", , true, false | »html | <spellcheck="true"> ... </ > | |
18. | style | = | CSS property:value | »html »img | <style="color:red"> ... </ > | |
19. | tabindex | = | integer | »img | <tabindex="3"> ... </ > | |
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="html page"> ... </ > | |
21. | translate | = | "", yes, no | »html »img | <translate="yes"> ... </ > | |
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration h1, h2, h3, h4, h5, h6 elements
HTML5 adding all headings in page
min | video details |
---|---|
00:04 | video tutorial: adding headings in page |
00:12 | saying you have the next headings you want to add into your HTML document |
00:17 | this is the main heading, so its rank should be 1 → h1 |
00:22 | this heading is right under the main heading, so its rank should be 2 → h2 |
00:28 | the next 3 headings can be placed on the same level but under h2, so their rank will be 3 → h3 |
00:38 | "day one Sistine Chapel", is a heading under h3 → its rank will be 4 → h4 |
00:44 | this heading is under h4 → its rank will be 5 → h5 |
00:47 | this heading is under h5 → its rank will be 6 → h6 |
00:51 | the rank of each heading has been decided, now we can add them (the headings) in page, using the tags: <h1>, <h2>, <h3>, <h4>, <h5>, <h6> |
02:10 | the biggest heading is h1 while the smallest is h6 |
02:18 | for example purpose: adding paragraphs e.g. a page with headings and paragraphs |
02:43 | you can add explicit sections in order to better structure your content: HTML5 way |
02:50 | in order to maintain the same semantic, 'Rome' heading will be nested inside a section |
02:57 | 'Colosseum', 'Pantheon', 'Sistine Chapel' will be nested inside a section INSIDE 'Rome's section |
02:59 | 'day one Sistine Chapel' heading will be nested inside a section INSIDE Sistine Chapel's section |
03:03 | and so on..we will continue to nest headings in sections INSIDE sections until we reach the corresponding rank for that heading |
03:10 | Example: nesting h2 (+ other tags) inside section element |
03:23 | nesting h3 (+ all other tags) inside section element INSIDE h2's section |
03:39 | nesting h4 (+ all other tags) inside section element INSIDE h3's section |
03:57 | nesting h5 (+ all other tags) inside section element INSIDE h4's section |
04:14 | nesting h6 inside section element INSIDE h5's section |
04:27 | the display and the semantic have been maintained |
04:40 | in order to avoid confusion: if you do not realize the appropriate heading rank for that nested section, better use h1 inside all nested sections like this: |
05:16 | the display and the semantic have been maintained in this case too |
05:25 | h1's and sections nested inside other sections in order to target the corresponding rank for our headings |