Heading classes help you quickly style titles and headings on your webpage with consistent sizes and spacing.
Heading classes in Bootsrap
<h1 class="display-1">Heading text</h1> <h2 class="display-2">Heading text</h2> <h3 class="display-3">Heading text</h3> <h4 class="display-4">Heading text</h4>
Use display-1 to display-4 classes for large, attention-grabbing headings.
These classes adjust font size and weight automatically for you.
display-1 class.<h1 class="display-1">Big Heading</h1>
display-3.<h2 class="display-3">Medium Heading</h2>
display-4.<h3 class="display-4">Smaller Heading</h3>
<h4>Normal Heading</h4>
This example shows how to use Bootstrap's heading classes display-1 to display-4 for big headings. The last heading uses the normal h5 tag without a display class.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap Heading Classes Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <main class="container py-4"> <h1 class="display-1">Display 1 Heading</h1> <h2 class="display-2">Display 2 Heading</h2> <h3 class="display-3">Display 3 Heading</h3> <h4 class="display-4">Display 4 Heading</h4> <h5>Normal h5 Heading</h5> </main> </body> </html>
Heading classes like display-1 are meant for large, eye-catching titles, not for regular paragraph text.
Always use semantic heading tags (h1 to h6) for accessibility, even when adding display classes.
Bootstrap's display classes adjust font size and weight but keep the heading's semantic meaning.
Use Bootstrap heading classes display-1 to display-4 for big, styled headings.
These classes make headings look consistent and attractive without extra CSS.
Keep using proper heading tags for good structure and accessibility.