Headings are block-level elements, ranging in size from h1 (the largest) down to h6 (the smallest).
Writing a heading is easy. The examples above were written like this.
Note that a heading is a block-level element, so that the default behaviour is to expand to fill the horizontal space available. Here is another example with some background colour added.
Some random heading
Headings define the start of a section or sub section of a page. As such you need to respect the order they appear on the page. This page (the one you are reading) is an exception, as we are describing how to do it!
It is important to remember that while you can technically make any text look like a heading, the heading tag itself has special meaning.
The h1 tag is a special case even amongst other headings. You should only ever use one such tag per page, as it describes the page heading. Again this page (the one you are reading) is an exception for obvious reasons.
Underneath the h1 tag comes h2. Hot on the heals of h2 is h3 and so on. You can see what we mean in the example below. Border have been added for clarity.
Search engines look for clearly defined sections to a page, to help them understand what a page is about. If you respect the proper order of headings you will be helping the search engines to index your pages appropriately and serve them up in search results.
If you break the order in any way, you risk the search engines ‘getting it wrong’.