A heading in HTML is often used to create a title or a sub-title. They are a big help to users who visit a web page and quickly browse the content.
This is because they indicate what the text which follows is about.
The other big plus with headings is that they help when it comes to SEO (Search Engine Optimization). They help tell search engines what your content is all about.
<h1> Look at me, I'm the largest (this is heading 1) </h1>
Look at me, I’m the largest (this is heading 1)
To create a heading in HTML, the <h></h> tag is used. There are six ( 6 ) different levels of heading that can be applied along with the heading tag. The numbers range from 1 to 6.
Each number corresponds to a specific level and produces a specific font size. The font sizes range from largest, <h1> to smallest, <h6>.
To get a heading, place some text between the opening and closing <h1> tag. Go ahead, give it a try yourself.
In order to get the other headings replace the <h1> with the respective heading you wish to use.
For example if you want to achieve heading 2 use <h2>, heading 3 <h3> and so forth.
<h2> I fall in between (this is heading 2) </h2> <h3> I fall in between (this is heading 3) </h3> <h4> I fall in between (this is heading 4) </h4> <h5> I fall in between (this is heading 5) </h5> <h6> I'm so tiny, I'm the smallest (this is heading 6) </h6>
Here’s what you get:
I fall in between (this is heading 2)
I fall in between (this is heading 3)
I fall in between (this is heading 4)
I fall in between (this is heading 5)
I’m so tiny, I’m the smallest (this is heading 6)
Another important thing to note is that when an heading is applied, a space is automatically produced before and after the heading.
So if you create a new heading, there isn’t necessarily a need to use the break tag <br> to create a new line. You can notice this in the output above.
Addressing the Head Confusion
Some people think the <head> tag in HTML is related to headings. But in fact, it isn’t. This tag is completely different. Headings are used in the content to bring proper structure to a page and help users and search engines identify what pages are all about.
Get to creating those headings!