Bird
Raised Fist0
Bootsrapmarkup~20 mins

Navbar color schemes in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Navbar Color Scheme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What color scheme does this Bootstrap navbar use?
Look at the navbar code below. What color scheme will the navbar have when rendered in a browser?
Bootsrap
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
  <a class="navbar-brand" href="#">Brand</a>
</nav>
ALight background with light text
BLight background with dark text
CDark background with light text
DTransparent background with dark text
Attempts:
2 left
💡 Hint
The class 'navbar-dark' changes text color to light, and 'bg-primary' sets a dark blue background.
📝 Syntax
intermediate
2:00remaining
Which option will cause a syntax error in this Bootstrap navbar?
Identify which navbar code snippet will cause a syntax error and fail to render correctly.
A
&lt;nav class="navbar navbar-light bg-light"&gt;
  &lt;a class="navbar-brand" href="#"&gt;Brand&lt;/a&gt;
&lt;/nav&gt;
B
&lt;nav class="navbar navbar-dark bg-dark"&gt;
  &lt;a class="navbar-brand" href="#"&gt;Brand&lt;/a&gt;
&lt;/nav&gt;
C
&gt;van/&lt;
&gt;a/&lt;dnarB&gt;"#"=ferh "dnarb-rabvan"=ssalc a&lt;  
&gt;"thgil-gb thgil-rabvan rabvan"=ssalc van&lt;
D
&lt;nav class="navbar navbar-dark bg-primary"&gt;
  &lt;a class="navbar-brand" href="#"&gt;Brand&lt;/a&gt;
&lt;/nav&gt;
Attempts:
2 left
💡 Hint
Check if all tags are properly closed.
❓ selector
advanced
2:00remaining
Which CSS selector targets the navbar brand text in Bootstrap?
Given a Bootstrap navbar, which CSS selector correctly selects the brand text link for styling?
Bootsrap
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Brand</a>
</nav>
A.navbar-brand a
B.navbar .navbar-brand
Cnav > .brand
D.navbar-brand > nav
Attempts:
2 left
💡 Hint
The brand text has class 'navbar-brand' inside an element with class 'navbar'.
❓ layout
advanced
2:00remaining
How does the 'navbar-expand-lg' class affect the navbar layout?
What is the effect of adding 'navbar-expand-lg' to a Bootstrap navbar?
Bootsrap
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Brand</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home</a>
      </li>
    </ul>
  </div>
</nav>
ANavbar expands only on extra small screens
BNavbar is always expanded horizontally on all screen sizes
CNavbar is always collapsed on all screen sizes
DNavbar expands horizontally on large screens and collapses on smaller screens
Attempts:
2 left
💡 Hint
'navbar-expand-lg' controls when the navbar changes from collapsed to expanded based on screen width.
❓ accessibility
expert
2:00remaining
Which attribute improves accessibility for the navbar toggle button?
In a Bootstrap navbar, which attribute on the toggle button best helps screen reader users understand its purpose?
Bootsrap
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
  <span class="navbar-toggler-icon"></span>
</button>
Aaria-label="Toggle navigation"
Balt="Toggle menu icon"
Ctabindex="-1"
Drole="button"
Attempts:
2 left
💡 Hint
Screen readers need a clear label describing the button's function.

Practice

(1/5)
1. Which Bootstrap class should you use to make the navbar text dark and suitable for a light background?
easy
A. navbar-dark
B. navbar-light
C. bg-dark
D. text-light

Solution

  1. Step 1: Understand navbar text color classes

    The navbar-light class makes text dark for readability on light backgrounds.
  2. Step 2: Match class to background type

    Since the background is light, navbar-light is appropriate, unlike navbar-dark which is for dark backgrounds.
  3. Final Answer:

    navbar-light -> Option B
  4. Quick Check:

    Light background needs dark text = navbar-light [OK]
Hint: Light background? Use navbar-light for dark text [OK]
Common Mistakes:
  • Confusing navbar-light with navbar-dark
  • Using bg-dark instead of navbar color scheme
  • Applying text-light on light backgrounds
2. Which of the following is the correct way to apply a dark navbar with a dark background in Bootstrap?
easy
A. <nav class='navbar navbar-light bg-dark'>
B. <nav class='navbar navbar-dark bg-light'>
C. <nav class='navbar navbar-light bg-light'>
D. <nav class='navbar navbar-dark bg-dark'>

Solution

  1. Step 1: Identify the correct navbar text color for dark background

    For dark backgrounds, navbar-dark ensures text is light and readable.
  2. Step 2: Match background color class

    The background class bg-dark sets a dark background color.
  3. Final Answer:

    <nav class='navbar navbar-dark bg-dark'> -> Option D
  4. Quick Check:

    Dark background needs navbar-dark + bg-dark [OK]
Hint: Dark background? Use navbar-dark with bg-dark [OK]
Common Mistakes:
  • Mixing navbar-light with bg-dark
  • Using bg-light with navbar-dark
  • Forgetting to include both navbar and bg classes
3. What will be the visible text color of the navbar brand in this code?
<nav class='navbar navbar-dark bg-primary'>
  <a class='navbar-brand' href='#'>Brand</a>
</nav>
medium
A. Dark text color
B. Primary blue text color
C. Light text color
D. Default black text color

Solution

  1. Step 1: Understand navbar-dark effect on text

    The navbar-dark class makes text light-colored for contrast on dark backgrounds.
  2. Step 2: Recognize bg-primary background

    bg-primary is a dark blue background, so light text is used for readability.
  3. Final Answer:

    Light text color -> Option C
  4. Quick Check:

    navbar-dark + dark bg = light text [OK]
Hint: navbar-dark means light text on dark backgrounds [OK]
Common Mistakes:
  • Assuming text matches bg-primary color
  • Thinking navbar-dark means dark text
  • Ignoring the effect of navbar-dark on text color
4. Identify the error in this navbar code snippet:
<nav class='navbar navbar-light bg-dark'>
  <a class='navbar-brand' href='#'>Brand</a>
</nav>
medium
A. Using navbar-light with a dark background
B. Missing navbar-expand class
C. Incorrect use of navbar-brand class
D. Missing href attribute in anchor tag

Solution

  1. Step 1: Check navbar color scheme consistency

    The class navbar-light is for light backgrounds, but bg-dark sets a dark background.
  2. Step 2: Understand readability issue

    This mismatch causes dark background with dark text, reducing readability.
  3. Final Answer:

    Using navbar-light with a dark background -> Option A
  4. Quick Check:

    navbar-light must pair with light backgrounds [OK]
Hint: Match navbar-light with light bg, navbar-dark with dark bg [OK]
Common Mistakes:
  • Ignoring navbar-expand necessity
  • Thinking navbar-brand needs href fix
  • Confusing navbar-light and navbar-dark usage
5. You want a navbar with a light background but dark text and a custom green background color using Bootstrap utilities. Which class combination is correct?
hard
A. navbar navbar-light bg-success
B. navbar navbar-dark bg-light
C. navbar navbar-light bg-light
D. navbar navbar-dark bg-success

Solution

  1. Step 1: Identify background color and text color needs

    You want a light background with dark text. The green background bg-success is a bright green, considered light.
  2. Step 2: Choose matching navbar text color class

    For light backgrounds, navbar-light is used to make text dark and readable.
  3. Final Answer:

    navbar navbar-light bg-success -> Option A
  4. Quick Check:

    Light bg (green) needs navbar-light for dark text [OK]
Hint: Light or bright bg? Use navbar-light for dark text [OK]
Common Mistakes:
  • Using navbar-dark with bright green background
  • Choosing bg-light instead of desired green
  • Mixing navbar-dark with light backgrounds
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard