What is HTML Headings?
An html heading is similar to a title or subtitle in a document. Headings can be defined with <h1> to <h6> tags, where <h1> being the largest heading and <h6> being the smallest.
Where to use HTML Headings?
- Headings can be used for topic headings, title, subtitle where it could be actually needed.
- It should not be used to make some texts big or bold.
- Headings are important for Search Engines to index the structure and content of the page. So <h1> can be used for main headings, <h2> for sub headings where less important can be given for <h3> to <h6> headings.
How to use HTML Headings?
- HTML headings are block elements (i.e., it takes up the full width available, with a new line before and after. The other type of element is inline element which takes up only as much as width it needs and does not force new lines. Inline elements would be place inside the block element).
- <h1>Some text</h1> is the correct way of using an heading tag. Similar way can be followed for other heading tags too.
- <h1> Some text, <h1><h2>Some Text</h2></h1> are the incorrect ways.
- Since heading tags are block elements, it has a line before and after as default. So no need of giving a line break.
- Headings cannot be assigned any unique attributes like bgcolor=”red” or color=”black”.
- It can be assigned only general terms like align=”center”, “left”, “right” and class, id, etc.
Example:
<html>
<head>
<title>HTML Heading Tutorial</title>
</head>
<body>
<h1 align=”center”>This is the main heading</h1>
<h2 align=”left”>This is the sub heading</h2>
<h3 align=”right”>Right aligned heading</h3>
<h4>This is small heading</h4>
<h5>This is the smaller heading</h5>
<h6>This is the smallest heading</h6>
</body>
</html>
<head>
<title>HTML Heading Tutorial</title>
</head>
<body>
<h1 align=”center”>This is the main heading</h1>
<h2 align=”left”>This is the sub heading</h2>
<h3 align=”right”>Right aligned heading</h3>
<h4>This is small heading</h4>
<h5>This is the smaller heading</h5>
<h6>This is the smallest heading</h6>
</body>
</html>
Next we can see about HTML paragraphs.
Advertisement