What Are H1 To H6 Tags In HTML?

ExploreEXPLORE THE CATALOGSupercharge your career with 700+ hands-on coursesView All CoursesPythonJavaJavaScriptCReactDockerVue JSRWeb DevDevOpsAWSC#LEARNING TOOLSExplore the industry's most complete learning platformCoursesLevel up your skillsSkill PathsAchieve learning goalsProjectsBuild real-world applicationsMock InterviewsNewAI-Powered interviewsPersonalized PathsGet the right resources for your goalsLEARN TO CODECheck out our beginner friendly courses.PricingFor BusinessResourcesNewsletterCurated insights on AI, Cloud & System DesignBlogFor developers, By developersFree CheatsheetsDownload handy guides for tech topicsAnswersTrusted answers to developer questionsGamesSharpen your skills with daily challengesSearchCoursesLog InJoin for freeWhat are h1 to h6 tags in HTML?

Headings are represented in HTML using heading elements. These range from h1-h6. Each heading is bold and has a different font size starting from h1 being the largest and h6 being the smallest.

Headings are used to separate portions of a webpage to improve navigation for the user. Headings of various fonts can allow us to use different headings for components such as titles, subtitles, sub-headings, and captions.

Syntax

The syntax of the heading elements is as follows:

<h1> This is Heading 1 </h1>

We begin by opening the tags using the <> sign. In between, we write the name of the element. It can range from h1 to h6 in our case. We then close the tags by using the </> sign. Once again, we will place the name of our tag in between <> and after the / symbol. Any text written between these tags will appear as a heading. All other heading elements can be written in a similar manner:

<h2> This is Heading 2 </h2> <h3> This is Heading 3 </h3> <h4> This is Heading 4 </h4> <h5> This is Heading 5 </h5> <h6> This is Heading 6 </h6>

Example

The following code snippet outputs each of the headings:

  • HTML
Run

We can also use CSS within the heading tags in order to style each heading. The syntax below shows how it can be done:

<h1> Heading </h1>

Inside the heading tags, we can add the style command that allows an attribute and its value.

Attributes refer to characteristics of the heading. These include background-color, color, text-align font-size etc.

A value is assigned to each attribute.

The code snippet below style each heading differently:

background-color changes the background color of the heading.

text-align positions the heading to either right, left, or center of the screen (as specified).

color changes the font color of the heading.

  • HTML
Run

Relevant Answers

Explore Courses

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved

Từ khóa » H1 Vs H6 Html