The h1 html tag
In HTML h tags stand for heading and this is split into 6 different h tags (h1, h2, h3, h4, h5 and h6). The <h1> tag itself is considered to be the main heading for a webpage. By default it is not only displayed bigger than the body and other h tags, but in SEO is considered an important ranking factor.When text is put between the opening and closing <h1> tag it is displayed as the main heading. A <h1> tag is only meant to be used once on a webpage, but if you code a webpage with more than one <h1> tag it will still display correctly.
<h1>Main header text</h1>
Any text between the opening and closing tag will be displayed as a main heading.
It is possible to style and add functionality to the <h1> tag, this is done by adding an attribute to after the h1 in the opening <h1> tag
Attributes allowed for the <h1>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<h1 id=”header”>Main header text</h1>
With all attributes there is a space after the initial h1 then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <h1> tag the id attribute is nearly always used over the class attribute although in practice it makes no difference.
The attribute style allows you to include css style information for a single <h1> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
<h1>Main header text</h1> – basic usage example.
<h1 id=”header”>Main header text</h1> – heading 1 which is styled by the id header.
<h1 class=”headerclass”> Main header text </h1> – heading 1 which is styled by the class headerclass.
<h1 id =”header” class=”headerclass”> Main header text </h1> – heading 1 which is styled by the class headerclass and the id header.
<h1 style=”color:#F00″>Main header text</h1> – heading 1 which has a custom colour of red.
<h1 dir=”rtl”>Main header text</h1> – heading 1 where the text reads from right to left.
<h1 lang=”uk”>Main header text</h1> – heading 1 where the language has been tagged as UK.
<h1 title=”ptitle”>Main header text</h1> – heading 1 where the tag has been titled ptitle.
Touching on just the surface of the <h1> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.