0
0
CSSmarkup~20 mins

Element selectors in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Element Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
Which CSS rule selects all

elements inside a

?
You want to style all

elements that are inside any

element. Which CSS selector will do this?
Asection > p { color: blue; }
Bp > section { color: blue; }
Cp section { color: blue; }
Dsection p { color: blue; }
Attempts:
2 left
💡 Hint
Think about the order of elements in the selector and the difference between descendant and child selectors.
selector
intermediate
2:00remaining
What does the selector 'ul > li' select?
Given the CSS selector ul > li, what elements will it select?
AAll <li> elements that are direct children of a <ul> element.
BAll <li> elements anywhere inside a <ul> element.
CAll <ul> elements that are children of <li> elements.
DAll <li> elements that are siblings of a <ul> element.
Attempts:
2 left
💡 Hint
The '>' symbol means direct child, not any descendant.
rendering
advanced
2:00remaining
What color will the

text be with this CSS?

Given this HTML and CSS, what color will the

text show in the browser?

<h1>Hello</h1>

h1 { color: red; }
h1 { color: blue !important; }
h1 { color: green; }

CSS
h1 { color: red; }
h1 { color: blue !important; }
h1 { color: green; }
ARed
BBlue
CGreen
DBlack (default)
Attempts:
2 left
💡 Hint
Remember that !important overrides normal declarations.
accessibility
advanced
2:00remaining
Which element selector best improves accessibility for screen readers?
You want to style all
Abutton { font-size: 1.5rem; }
B.btn { font-size: 1.5rem; }
C#button { font-size: 1.5rem; }
D* { font-size: 1.5rem; }
Attempts:
2 left
💡 Hint
Think about selecting elements by their tag name versus classes or IDs.
🧠 Conceptual
expert
2:00remaining
How many
  • elements are selected by 'nav ul li' in this HTML?
  • Given this HTML:
    <nav>
      <ul>
        <li>Home</li>
        <li>About</li>
        <li>Services</li>
      </ul>
    </nav>
    <ul>
      <li>Outside</li>
    </ul>

    How many <li> elements will the selector nav ul li select?
    A0
    B4
    C3
    D1
    Attempts:
    2 left
    💡 Hint
    Count only
  • elements inside
      inside