Friday, March 24, 2023

How to use HTML headings tag

 

HTML headings are used to define the hierarchy and structure of a webpage's content. They are typically used to indicate the main headings and subheadings of a page, and are denoted by the <h1> to <h6> tags.

Here's a brief overview of the different HTML headings tags:

<h1> :- Defines the most important heading on the page. It should be used sparingly and only once per page.

<h2> :- Defines a second-level heading on the page, typically used to separate major sections of content.

<h3> to <h6> :- Defines third-level to sixth-level headings respectively. These are typically used for subheadings within sections.

Here's an example of how headings can be used in HTML :

 

<!DOCTYPE html>

<html>

  <head>

    <title>My Page</title>

  </head>

  <body>

    <h1>Main Heading</h1>

    <p>This is the main content of the page.</p>

    <h2>Section One</h2>

    <p>This is the first section of the page.</p>

    <h3>Subheading One</h3>

    <p>This is a subheading within the first section.</p>

    <h3>Subheading Two</h3>

    <p>This is another subheading within the first section.</p>

    <h2>Section Two</h2>

    <p>This is the second section of the page.</p>

    <h3>Subheading Three</h3>

    <p>This is a subheading within the second section.</p>

  </body>

</html>

 

In this example, the <h1> tag is used to define the main heading of the page, followed by two <h2> tags for major sections of content. Within the first section, two <h3> tags are used to define subheadings. The second section also has one <h3> tag for a subheading.

(Note :- Copy this code and paste it in notepad and then save it as filename.html and then open the file in any browser.)

No comments:

Post a Comment