HTML Tutorial

HTML Tag: <h2>

Usage of <h2>:

  • Used to create sub-headings in an HTML document.
  • Represents a secondary heading, less important than <h1> but more important than <h3>.

Attributes of <h2>:

  • id: Unique identifier for the heading.
  • class: Used for styling or applying CSS classes.
  • style: Inline styling attributes.

Examples with <h2>:

<h2>Main Heading</h2>
<h3>Sub-Heading 1</h3>
<h2>Another Main Heading</h2>

Simple HTML Example: Exploring the <h2> Tag

<!DOCTYPE html>
<html>
<head>
  <title><h2> Tag Example</title>
</head>
<body>
  <h1>Main Heading</h1>
  <h2>Secondary Heading</h2>
  <p>This is the body text.</p>
</body>
</html>