Create a Bootstrap Card with Header, Body, and Footer
📖 Scenario: You are building a simple user profile card for a website. The card should have a header with the user's name, a body with a short description, and a footer with a contact button.
🎯 Goal: Build a Bootstrap card component with a header, body, and footer sections using the correct Bootstrap classes.
📋 What You'll Learn
Use Bootstrap 5 classes for the card structure
Create a card with a header containing the text 'John Doe'
Add a card body with the text 'Web developer and designer.'
Include a card footer with a button labeled 'Contact'
Ensure semantic HTML and accessibility with proper roles and labels
💡 Why This Matters
🌍 Real World
Cards are common UI elements used to display grouped information like user profiles, product details, or blog posts in a clean, organized way.
💼 Career
Knowing how to build Bootstrap cards is useful for front-end developers and web designers to create visually appealing and consistent layouts quickly.
Progress0 / 4 steps
1
Create the basic Bootstrap card container
Write the opening <div> tag with the Bootstrap class card to start the card container.
Bootsrap
Hint
Use a div with class card to create the card container.
2
Add the card header with the user's name
Inside the div with class card, add another div with class card-header containing the exact text John Doe.
Bootsrap
Hint
Use a div with class card-header and put the text John Doe inside.
3
Add the card body with a short description
Below the card header, add a div with class card-body containing the exact text Web developer and designer..
Bootsrap
Hint
Use a div with class card-body and add the text inside.
4
Add the card footer with a contact button
Below the card body, add a div with class card-footer. Inside it, add a button with classes btn btn-primary and the exact label Contact.
Bootsrap
Hint
Use a div with class card-footer and inside it add a button with classes btn btn-primary and text Contact.
Practice
(1/5)
1. Which Bootstrap class is used to create the header section of a card?
easy
A. card-top
B. card-header
C. card-title
D. card-head
Solution
Step 1: Understand Bootstrap card parts
Bootstrap cards have specific classes for each part: header, body, and footer.
Step 2: Identify the header class
The class card-header is used to style the header section of a card.
Final Answer:
card-header -> Option B
Quick Check:
Header section class = card-header [OK]
Hint: Header always uses card-header class [OK]
Common Mistakes:
Confusing card-title with header
Using non-existent classes like card-top
Mixing header with body or footer classes
2. Which is the correct HTML structure for a Bootstrap card body?
easy
A. <div class='card-body'>Content</div>
B. <section class='card-body'>Content</section>
C. <div class='card-content'>Content</div>
D. <body class='card'>Content</body>
Solution
Step 1: Identify the correct tag and class for card body
Bootstrap uses a div with class card-body to hold the main content.
Step 2: Check the options for correct syntax
<div class='card-body'>Content</div> uses <div class='card-body'>, which is the standard Bootstrap structure.
Final Answer:
<div class='card-body'>Content</div> -> Option A
Quick Check:
Card body uses div.card-body [OK]
Hint: Card body is always a div with class card-body [OK]
Common Mistakes:
Using wrong tags like section or body
Using incorrect class names like card-content
Placing content outside the card body div
3. What will be the visual order of sections in this Bootstrap card HTML?
C. No error; this is correct Bootstrap card structure
D. Header must be inside card-body
Solution
Step 1: Check container class
The outer div has class card, which is correct.
Step 2: Verify card parts order and nesting
Header, body, and footer are correctly placed as siblings inside the card container.
Final Answer:
No error; this is correct Bootstrap card structure -> Option C
Quick Check:
Proper card structure = No error [OK]
Hint: Card parts are siblings inside div.card [OK]
Common Mistakes:
Thinking footer must come before body
Placing header inside body incorrectly
Forgetting the main card container class
5. You want a card with a header, body, and footer. The footer should have a button aligned to the right. Which Bootstrap classes help achieve this layout inside the footer?
hard
A. card-footer d-flex justify-content-end
B. card-footer text-center
C. card-footer align-items-start
D. card-footer float-right
Solution
Step 1: Use card-footer for footer section
The footer must have the card-footer class to style it as a card footer.
Step 2: Align button right using Flexbox utilities
Bootstrap's d-flex makes the footer a flex container, and justify-content-end pushes content to the right.
Final Answer:
card-footer d-flex justify-content-end -> Option A
Quick Check:
Right aligned footer button = d-flex justify-content-end [OK]
Hint: Use flex and justify-content-end to align right [OK]
Common Mistakes:
Using deprecated float-right class
Using text-center which centers content
Using align-items-start which aligns vertically
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.