📖 Scenario: You are creating a simple webpage that shows different heading styles using Bootstrap. This will help you understand how to use Bootstrap's heading classes to style text.
🎯 Goal: Build a webpage that displays six headings from h1 to h6 using Bootstrap classes display-1 to display-6.
📋 What You'll Learn
Use Bootstrap 5 CSS from CDN
Create headings with classes display-1 to display-6
Use semantic HTML5 structure
Make sure the page is responsive and accessible
💡 Why This Matters
🌍 Real World
Websites often use headings to organize content clearly and Bootstrap helps style them easily and consistently.
💼 Career
Knowing how to use Bootstrap for headings is useful for front-end developers to create visually appealing and accessible webpages quickly.
Progress0 / 4 steps
1
Create the basic HTML structure with Bootstrap link
Create a basic HTML5 page with lang="en" and charset="UTF-8". Add the Bootstrap 5 CSS CDN link inside the <head>. Include a <main> section with a container <div class="container"> inside the <body>.
Bootsrap
Hint
Remember to include the Bootstrap CSS link inside the <head> section.
2
Add the first heading with class display-1
Inside the <div class="container">, add an <h1> heading with the text Display Heading 1 and the Bootstrap class display-1.
Bootsrap
Hint
Use an <h1> tag with class display-1 and the exact text Display Heading 1.
3
Add headings from display-2 to display-6
Below the <h1> heading, add five more headings: <h2> with class display-2 and text Display Heading 2, <h3> with class display-3 and text Display Heading 3, <h4> with class display-4 and text Display Heading 4, <h5> with class display-5 and text Display Heading 5, and <h6> with class display-6 and text Display Heading 6.
Bootsrap
Hint
Use the correct heading tags <h2> to <h6> with matching Bootstrap classes and text.
4
Add a page header with <header> and accessibility
Wrap all the headings inside a <header> element inside the container. Add an aria-label="Page headings" attribute to the <header> for accessibility.
Bootsrap
Hint
Use a <header> tag with aria-label="Page headings" wrapping all the heading tags.
Practice
(1/5)
1. What is the main purpose of using Bootstrap display heading classes like display-1 to display-4?
easy
A. To hide headings on small screens
B. To change the background color of headings
C. To add animations to headings
D. To make headings larger and more prominent on the page
Solution
Step 1: Understand Bootstrap display classes
Bootstrap display classes like display-1 to display-4 are used to style headings with bigger and bolder text.
Step 2: Identify the purpose of these classes
The main goal is to make headings stand out by increasing their size and weight, not to change colors or add animations.
Final Answer:
To make headings larger and more prominent on the page -> Option D
Quick Check:
Display classes = bigger, bold headings [OK]
Hint: Display classes make headings big and bold fast [OK]
Common Mistakes:
Thinking display classes change colors
Confusing display classes with animation classes
Assuming display classes hide elements
2. Which of the following is the correct way to apply a Bootstrap display heading class to an <h1> tag?
easy
A. <h1>display-3 Title</h1>
B. <h1 display-3>Title</h1>
C. <h1 class="display-3">Title</h1>
D. <h1 class="title display3">Title</h1>
Solution
Step 1: Recall Bootstrap class syntax
Bootstrap classes are added using the class attribute with the exact class name, e.g., class="display-3".
Step 2: Check each option for correct syntax
<h1 class="display-3">Title</h1> uses class="display-3" correctly. Other options misuse attribute syntax or class names.
Final Answer:
<h1 class="display-3">Title</h1> -> Option C
Quick Check:
Use class="display-x" for display headings [OK]
Hint: Always use class="display-x" syntax for Bootstrap classes [OK]
Common Mistakes:
Omitting the class attribute
Writing class names without quotes
Using incorrect attribute names
3. What will be the visual difference between these two headings in a Bootstrap page?
Hint: Remember display classes have a dash: display-1, display-2, etc. [OK]
Common Mistakes:
Omitting the dash in class names
Thinking display classes only work on <h1>
Missing quotes around class attribute
5. You want to create a page with a main heading that is very large and bold, and a subheading that is smaller but still styled with Bootstrap display classes. Which combination is correct?
hard
A. <h1 class="display-1">Main Title</h1> <h2 class="display-4">Sub Title</h2>
B. <h1 class="display-4">Main Title</h1> <h2 class="display-1">Sub Title</h2>
C. <h1>Main Title</h1> <h2>Sub Title</h2>
D. <h1 class="display-5">Main Title</h1> <h2 class="display-3">Sub Title</h2>
Solution
Step 1: Understand Bootstrap display class sizes
Display classes range from display-1 (largest) to display-4 (smaller). There is no display-5.
Step 2: Choose correct class order for main and subheading
Main heading should use display-1 for biggest size, subheading can use display-4 for smaller but styled text.
Step 3: Verify semantic tags and classes
<h1 class="display-1">Main Title</h1> <h2 class="display-4">Sub Title</h2> uses correct classes and semantic tags. Other combinations either use non-existent classes like display-5, reverse the size order (smaller main heading with display-4, larger subheading with display-1), or omit display classes entirely.
Final Answer:
<h1 class="display-1">Main Title</h1> <h2 class="display-4">Sub Title</h2> -> Option A
Quick Check:
Main heading bigger with display-1, subheading smaller display-4 [OK]
Hint: Use display-1 for main, display-4 for subheading [OK]
Common Mistakes:
Using display classes in wrong size order
Using non-existent display-5 class
Not applying display classes to subheading
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.