📖 Scenario: You want to create a simple web page using Bootstrap to make it look nice and responsive on all devices.
🎯 Goal: Build a basic Bootstrap page with a header, a navigation bar, and a main content area with a welcoming message.
📋 What You'll Learn
Include Bootstrap CSS from the official CDN
Use semantic HTML5 elements like ,
Add a responsive navigation bar with three links
Add a container with a heading and a paragraph in the main content
Make sure the page is mobile-friendly with the viewport meta tag
💡 Why This Matters
🌍 Real World
Bootstrap is widely used to quickly build responsive and visually appealing websites without writing complex CSS from scratch.
💼 Career
Knowing how to create a Bootstrap page is essential for front-end web developers to build professional and mobile-friendly websites efficiently.
Progress0 / 4 steps
1
Create the basic HTML structure with Bootstrap CSS link
Create an HTML5 skeleton with lang="en" in the <html> tag. Inside the <head>, add the charset="UTF-8" meta tag, the viewport meta tag name="viewport" content="width=device-width, initial-scale=1", and link the Bootstrap CSS from https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css using a <link> tag with rel="stylesheet". Also add a <title> with the text My Bootstrap Page. Leave the <body> empty for now.
Bootsrap
Hint
Remember to add the viewport meta tag for mobile devices and link Bootstrap CSS from the official CDN.
2
Add a header with a navigation bar
Inside the <body>, add a <header> element. Inside it, create a Bootstrap navigation bar using a <nav> with classes navbar and bg-light. Inside the nav, add a <div> with class container-fluid. Inside this div, add a <a> with class navbar-brand and text MySite. Then add a <ul> with class navbar-nav and three <li> items each containing an <a> with class nav-link and text Home, About, and Contact respectively. Use href="#" for all links.
Bootsrap
Hint
Use Bootstrap classes navbar, bg-light, container-fluid, navbar-brand, navbar-nav, nav-item, and nav-link to build the navigation bar.
3
Add the main content container with heading and paragraph
Below the <header>, add a <main> element. Inside it, add a <div> with class container. Inside this container, add an <h1> with the text Welcome to My Bootstrap Page and a <p> with the text This is a simple page using Bootstrap for styling and layout..
Bootsrap
Hint
Use a Bootstrap container to center your content and add spacing. Put your heading and paragraph inside it.
4
Add Bootstrap JavaScript bundle and finalize the page
At the end of the <body> but before the closing </body> tag, add a <script> tag that loads the Bootstrap JavaScript bundle from https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js. This will enable interactive Bootstrap components if needed. Make sure the integrity and crossorigin attributes are not required for this exercise.
Bootsrap
Hint
Add the Bootstrap JavaScript bundle at the end of the body to enable interactive features.
Practice
(1/5)
1. What is the main purpose of including Bootstrap CSS in your HTML page?
easy
A. To create backend server logic
B. To apply ready-made styles and layout to your webpage quickly
C. To make your page load faster by compressing images
D. To add interactive JavaScript features only
Solution
Step 1: Understand Bootstrap CSS role
Bootstrap CSS provides pre-built styles and layout helpers to style HTML elements easily.
Step 2: Differentiate CSS from JS and backend
CSS controls appearance, not backend logic or image compression, and JS adds interactivity but is separate.
Final Answer:
To apply ready-made styles and layout to your webpage quickly -> Option B
Quick Check:
Bootstrap CSS = ready styles [OK]
Hint: Bootstrap CSS styles your page fast, not backend or speed [OK]
Common Mistakes:
Confusing Bootstrap CSS with JavaScript functionality
Thinking Bootstrap compresses images
Assuming Bootstrap handles backend logic
2. Which of the following is the correct way to include Bootstrap CSS from a CDN in your HTML <head>?
easy
A.
B.
C.
D.
Solution
Step 1: Identify correct HTML tag for CSS
CSS files are included using the <link> tag with rel="stylesheet" attribute.
Step 2: Check the CDN URL and tag correctness
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> uses <link> with correct href to Bootstrap CSS CDN, others misuse tags or attributes.
Final Answer:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> -> Option C
Quick Check:
CSS uses <link rel="stylesheet"> [OK]
Hint: Use for CSS files [OK]
Common Mistakes:
Using <script> tag for CSS files
Using <style> tag with src attribute
Wrong attribute values like rel="script"
3. What will be the visual result of this HTML snippet using Bootstrap?
A. Container class should be 'container-fluid' instead
B. Button class 'btn-primary' is misspelled
C. Missing closing tag for <button>
D. Bootstrap CSS file path is likely incorrect or missing CDN link
Solution
Step 1: Check Bootstrap CSS inclusion
The link uses 'bootstrap.min.css' without a full path or CDN, which may cause the file not to load if not locally present.
Step 2: Verify other elements
Button class spelling is correct, button tag is properly closed, and 'container' is valid Bootstrap class.
Final Answer:
Bootstrap CSS file path is likely incorrect or missing CDN link -> Option D
Quick Check:
Missing or wrong CSS link breaks Bootstrap styles [OK]
Hint: Always use full CDN URL or correct local path for Bootstrap CSS [OK]
Common Mistakes:
Assuming local CSS file always exists
Confusing container and container-fluid classes
Overlooking missing or wrong file paths
5. You want to create a simple Bootstrap page with a navigation bar and a button below it. Which of the following code snippets correctly sets up the basic Bootstrap page structure including CSS and JS from CDN?