📖 Scenario: You are creating a simple webpage to showcase different shadow effects on boxes using Bootstrap's shadow utilities. Shadows help elements stand out by adding depth, like how a picture frame casts a shadow on a wall.
🎯 Goal: Build a webpage with four colored boxes, each demonstrating a different Bootstrap shadow utility class: shadow-none, shadow-sm, shadow, and shadow-lg. This will help you see how shadows change the look of elements.
📋 What You'll Learn
Use Bootstrap 5 CSS via CDN
Create four div elements with background colors and fixed size
Apply the shadow utility classes shadow-none, shadow-sm, shadow, and shadow-lg respectively
Arrange the boxes vertically with spacing
Include semantic HTML structure and responsive viewport meta tag
💡 Why This Matters
🌍 Real World
Shadows are used in web design to create depth and highlight important elements, making interfaces more visually appealing and easier to understand.
💼 Career
Knowing how to use Bootstrap utilities like shadows helps you quickly style web components in professional projects, improving UI design and user experience.
Progress0 / 4 steps
1
Set up the basic HTML structure with Bootstrap CSS
Create a basic HTML5 page with lang="en", charset="UTF-8", and a viewport meta tag for responsiveness. Include the Bootstrap 5 CSS CDN link inside the <head>. Add a <main> section with a container <div> that will hold the shadow boxes.
Bootsrap
Hint
Remember to include the Bootstrap CSS link from the official CDN inside the <head> section.
2
Create four colored boxes inside the container
Inside the div with class container, create four div elements. Each should have a fixed width and height of 5rem, a margin bottom of 3rem, and a background color: bg-primary, bg-success, bg-warning, and bg-danger respectively. Do not add shadow classes yet.
Bootsrap
Hint
Use inline styles for width and height. Use Bootstrap margin bottom class mb-3 for spacing.
3
Add Bootstrap shadow utility classes to each box
Add the shadow utility classes to each colored box div in this order: first box gets shadow-none, second box gets shadow-sm, third box gets shadow, and fourth box gets shadow-lg. Keep the existing classes and styles.
Bootsrap
Hint
Keep the existing classes and add the shadow classes separated by spaces.
4
Add a heading and improve accessibility
Above the container div, add a <h1> heading with the text Bootstrap Shadow Utilities Demo. Add an aria-label attribute with the value Shadow boxes demonstration to the main element for accessibility.
Bootsrap
Hint
Place the heading inside main but before the container. Add the aria-label attribute to the main tag.
Practice
(1/5)
1. What does the Bootstrap class shadow-lg do to an element?
easy
A. Changes the element's background color
B. Removes any shadow from the element
C. Adds a small shadow around the element
D. Adds a large shadow around the element to create depth
Solution
Step 1: Understand shadow utility classes
Bootstrap provides shadow classes to add shadows of different sizes to elements.
Step 2: Identify the effect of shadow-lg
The shadow-lg class adds a large shadow, making the element appear raised and deeper.
Final Answer:
Adds a large shadow around the element to create depth -> Option D
Quick Check:
shadow-lg means large shadow [OK]
Hint: Remember: lg means large shadow size [OK]
Common Mistakes:
Confusing shadow-lg with shadow-none
Thinking shadow-lg changes background color
Mixing shadow-lg with shadow-sm
2. Which of the following is the correct way to remove a shadow from a Bootstrap element?
easy
A. Add class shadow-remove
B. Add class shadow-none
C. Add class no-shadow
D. Add class shadow-zero
Solution
Step 1: Recall Bootstrap shadow removal class
Bootstrap uses shadow-none to remove shadows from elements.
Step 2: Check the options for the correct class
Only shadow-none is a valid Bootstrap class to remove shadows.
Final Answer:
Add class shadow-none -> Option B
Quick Check:
shadow-none removes shadows [OK]
Hint: Use shadow-none to remove shadows, not shadow-remove [OK]
Common Mistakes:
Using non-existent classes like shadow-remove
Confusing shadow-none with shadow-zero
Trying to remove shadow by removing other classes
3. What shadow effect will the following HTML produce?