Table of Content
Headings are like the headlines of your content. They help divide your text into smaller, more manageable sections. Just like a magazine article has titles, subtitles, and sub-subtitles, headings help organize your content in a similar way by creating an outline.
Headings serve several important purposes:
Headings also play a role in Search Engine Optimization (SEO). Search engines like Google use headings to understand the structure of your content and identify its main topics. By using relevant and descriptive headings, you can improve your website's visibility and ranking in search results.
Imagine you're reading a textbook. Each chapter is divided into sections, each with a title. Those titles are like headings. They help you quickly jump to the part you're interested in without reading the whole chapter. Headings also make it easier to skim the text and find the main ideas without having to read everything.
Headings are used to organize and structure content on a web page. They come in different sizes, with <h1> being the largest and <h6> the smallest.
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 2</h3>
<h4>Heading 2</h4>
<h5>Heading 2</h5>
<h6>Heading 6</h6>
Inline styles can be added to headings to change their appearance. For example:
<h1 style="color: red; text-align: center;">Heading 1</h1>
This code would make the heading red and center-aligned.
Headings can be nested within each other to create a logical flow of information:
<h1>Main Heading</h1>
<h2>Subheading</h2>
<h3>Sub-subheading</h3>
This structure helps users navigate the content easily.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Headings Example</title>
</head>
<body>
<h1>Welcome to Code Junction</h1>
<h2 style="color: blue; text-align: center;">About Us</h2>
<h3 style="font-weight: bold;">Skills that you will learn</h3>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<h6>Contact Us</h6>
<p>Email: support@codejn.com</p>
</body>
</html>
This code creates a web page with a main heading, subheading, sub-subheading, list of skills, and contact information. The headings are used to guide the reader through the content.
Imagine a storybook with chapters and sections. Headings are like the chapter and section titles that help readers navigate the book. They tell you the main idea of each part.
Just like chapters and sections make a book easy to read, headings make a webpage or document easy to understand. They break up the text into manageable chunks, making it easier to skim and find the information you need.
Too many headings can be like too many chapters in a book. It can make the story confusing. Use headings only when they truly help the reader understand the structure and main ideas of your text.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Improper Heading Example</title>
<style>
h1, h3, h4 {
border: 2px solid red;
}
</style>
</head>
<body>
<h1>Main Title</h1>
<h3>Subsection Title</h3>
<p>Some content under subsection.</p>
<h4>Another Subsection Title</h4>
<p>More content under another subsection.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proper Heading Example</title>
<style>
h1, h2, h3 {
border: 2px solid green;
}
</style>
</head>
<body>
<h1>Main Title</h1>
<h2>Section Title</h2>
<p>Some content under section.</p>
<h3>Subsection Title</h3>
<p>More content under subsection.</p>
</body>
</html>
Imagine you're writing an essay about different animals. You start with an introduction, then write a heading about "Mammals". Under that heading, you write about dogs and cats. But wait! Under the heading "Mammals", you also write about fish. This is improper nesting because fish are not mammals.
- Introduction
- Heading: Mammals
- Dogs
- Cats
- Fish ❌
- Introduction
- Heading: Mammals
- Dogs
- Cats
- Heading: Fish
Headings are meant to outline the structure of your document, not to make it look pretty. Don't use headings just to bold or italicize text. Screen readers won't be able to understand the hierarchy of your document if you do this.
Screen readers are software that helps people with visual impairments read digital documents. Headings are important for screen readers because they allow users to quickly navigate to different sections of your document. If you don't use headings correctly, screen readers won't be able to understand the structure of your document and your users will have a hard time navigating it.
What are html headings?
How many headings are there in HTML?
Can I use multiple (<h1>) tags on a single page?
How should I structure headings for SEO?
What is the impact of headings on accessibility?
Can I style HTML headings with CSS?
Is it necessary to use headings in a specific order?
Can headings contain other HTML elements?
Do headings affect the visual layout of a webpage?