How to set Heading alignment in HTML?


Headings are the titles or subtitles of the content that you want to display on the web page. Headings help us to get an idea of the content on the web page. Headings and subheadings represent the key concepts ideas and supporting ideas in the content of the web page. HTML have a different level of heading tags.

Heading is defined with <h1> to <h6> tags. It is important to use headings to show the HTML document structure. <h1> headings should be used for main headings, followed by <h2> headings, then <h3>, and so on up to <h6>.

Heading tags in HTML have <h1> to <h6> tags. To set the heading alignment in HTML, we use the style attribute inside an HTML element. The attribute is used with the HTML <h1> to <h6> tag, with the CSS property text-align for setting alignment for an element.

Syntax

Following is the syntax for the heading alignment in HTML.

<h1 align="left | right | center | justify">

Example

Following is the example program for the heading alignment in the center.

<!DOCTYPE html> <html> <body> <h1 align="center">Tutorials point </h1> </body> </html>

Heading alignment to left

We can align the heading to left by using the below syntax.

Syntax

Following is the syntax for the heading alignment on left.

<h1 align="left">The text…</h1>

Example

Following is the example program for the heading alignment on left.

<!DOCTYPE html> <html> <body> <h1 align="left">Tutorials point</h1> </body> </html>

Heading alignment to left

We can align the heading to right by using the below syntax.

Syntax

Following is the syntax for the heading alignment on right in HTML.

<h1 align="right">The text…</h1>

Example

Following is the example program for the heading alignment on right.

<!DOCTYPE html> <html> <body> <h1 align="right">Tutorials point</h1> </body> </html>

Heading alignment to justify

We can align the heading to justify by using the below syntax.

Syntax

Following is the syntax for the heading alignment in justify in HTML.

<h1 align="justify">The text…</h1>

Example

Following is the example program for the heading alignment in justify.

<!DOCTYPE html> <html> <body> <h1 align="justify">Tutorials point</h1> </body> </html>

Updated on: 02-Sep-2023

46K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements