HTML Headings
HTML Headings
HTML headings are used to define the structure and hierarchy of content on a web page. There are six levels of headings, from <h1>
(most important) to <h6>
(least important).
Usage of Headings
<h1>
: Represents the main heading of a page. It should be used only once per page and should describe the overall content.<h2>
to<h6>
: Used for subheadings or sections within the page. Each subsequent level indicates a lower level of importance.
Example:
<h1>Main Heading</h1>
<h2>Subheading 1</h2>
<h3>Sub-subheading 1.1</h3>
<h2>Subheading 2</h2>
<h3>Sub-subheading 2.1</h3>
Best Practices
- Use headings to logically structure your content. Avoid using headings for styling purposes only.
- Ensure a hierarchical order in your headings. For example, don’t use an
<h3>
directly after an<h1>
. - Use CSS to style headings for visual presentation while keeping the semantic structure intact.