← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 414 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
  2. 2.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    .menu { color: black; }
    h1 { color: red; }
    #logo { color: purple; }
    (a) purple (b) black (c) yellow (d) red
  3. 3.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    .menu { color: orange; }
    .menu { color: red; }
    (a) green (b) black (c) orange (d) red
  4. 4.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    #logo { color: purple; }
    .star { color: green; }
    (a) green (b) purple (c) blue (d) yellow
  5. 5.⚖️ What colour is the text of this element?
    <h1 class="box" id="end">Hi</h1>
    CSS:
    h1 { color: orange; }
    #end { color: yellow; }
    .box { color: blue; }
    (a) orange (b) blue (c) green (d) yellow
  6. 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
  7. 7.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    .note { color: purple; }
    .note { color: green; }
    (a) purple (b) white (c) red (d) green
  8. 8.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: white; }
    (a) blue (b) white (c) green (d) purple
  9. 9.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    .red { color: orange; }
    .red { color: red; }
    (a) orange (b) yellow (c) black (d) red
  10. 10.⚖️ What colour is the text of this element?
    <h1 class="red" id="logo">Hi</h1>
    CSS:
    .red { color: orange; }
    h1 { color: blue; }
    (a) purple (b) blue (c) orange (d) red
  11. 11.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  12. 12.⚖️ What colour is the text of this element?
    <h2 class="box" id="hero">Hi</h2>
    CSS:
    #hero { color: yellow; }
    #hero { color: red; }
    (a) white (b) black (c) red (d) yellow
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="red" id="logo">Hi</h2>
    CSS:
    h2 { color: purple; }
    #logo { color: red; }
    (a) black (b) blue (c) red (d) purple
  14. 14.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    .note { color: blue; }
    .note { color: orange; }
    (a) blue (b) orange (c) green (d) yellow
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    #hero { color: white; }
    #hero { color: orange; }
    (a) yellow (b) orange (c) green (d) white
  16. 16.⚖️ What colour is the text of this element?
    <h1 class="star" id="main">Hi</h1>
    CSS:
    #main { color: blue; }
    .star { color: green; }
    (a) green (b) purple (c) red (d) blue
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="red" id="main">Hi</h1>
    CSS:
    .red { color: green; }
    #main { color: orange; }
    h1 { color: red; }
    (a) yellow (b) green (c) red (d) orange
  18. 18.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    .red { color: yellow; }
    .red { color: blue; }
    (a) green (b) blue (c) yellow (d) red
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="red" id="top">Hi</h2>
    CSS:
    .red { color: yellow; }
    .red { color: blue; }
    (a) black (b) yellow (c) white (d) blue
  20. 20.⚖️ What colour is the text of this element?
    <p class="red" id="hero">Hi</p>
    CSS:
    #hero { color: black; }
    #hero { color: blue; }
    (a) blue (b) green (c) black (d) red
  21. 21.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    #intro { color: blue; }
    #intro { color: green; }
    (a) blue (b) black (c) yellow (d) green
  22. 22.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    h1 { color: red; }
    h1 { color: blue; }
    (a) blue (b) purple (c) black (d) red
  23. 23.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    h2 { color: purple; }
    h2 { color: black; }
    (a) blue (b) white (c) purple (d) black
  24. 24.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    p { color: black; }
    p { color: blue; }
    (a) black (b) green (c) red (d) blue
  25. 25.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    #end { color: black; }
    p { color: white; }
    (a) white (b) black (c) red (d) yellow
  26. 26.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    #main { color: red; }
    h2 { color: green; }
    (a) yellow (b) purple (c) green (d) red
  27. 27.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    .big { color: yellow; }
    h2 { color: white; }
    #logo { color: blue; }
    (a) green (b) blue (c) white (d) yellow
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="red" id="logo">Hi</h2>
    CSS:
    .red { color: orange; }
    h2 { color: white; }
    (a) red (b) blue (c) white (d) orange
  29. 29.⚖️ What colour is the text of this element?
    <h1 class="big" id="intro">Hi</h1>
    CSS:
    h1 { color: green; }
    h1 { color: blue; }
    (a) blue (b) white (c) green (d) orange
  30. 30.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    .big { color: purple; }
    .big { color: orange; }
    (a) blue (b) red (c) purple (d) orange
  31. 31.⚖️ What colour is the text of this element?
    <p class="big" id="hero">Hi</p>
    CSS:
    p { color: red; }
    p { color: green; }
    (a) red (b) green (c) white (d) black
  32. 32.⚖️ What colour is the text of this element?
    <p class="star" id="intro">Hi</p>
    CSS:
    .star { color: red; }
    .star { color: blue; }
    (a) blue (b) white (c) red (d) yellow
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: blue; }
    (a) purple (b) red (c) blue (d) green
  34. 34.⚖️ What colour is the text of this element?
    <h1 class="box" id="logo">Hi</h1>
    CSS:
    h1 { color: blue; }
    .box { color: purple; }
    (a) red (b) blue (c) orange (d) purple
  35. 35.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    p { color: green; }
    .box { color: black; }
    #end { color: blue; }
    (a) blue (b) green (c) black (d) red
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    h1 { color: black; }
    .box { color: yellow; }
    #top { color: green; }
    (a) yellow (b) green (c) black (d) purple
  37. 37.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    #end { color: red; }
    .box { color: green; }
    p { color: yellow; }
    (a) red (b) yellow (c) green (d) purple
  38. 38.⚖️ What colour is the text of this element?
    <h1 class="menu" id="main">Hi</h1>
    CSS:
    h1 { color: black; }
    .menu { color: yellow; }
    #main { color: white; }
    (a) yellow (b) green (c) black (d) white
  39. 39.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    p { color: red; }
    .note { color: yellow; }
    #logo { color: orange; }
    (a) yellow (b) blue (c) red (d) orange
  40. 40.⚖️ What colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    .big { color: purple; }
    h1 { color: black; }
    #hero { color: white; }
    (a) purple (b) blue (c) white (d) black

Answer key

  1. an id selector
  2. purple
  3. red
  4. purple
  5. yellow
  6. the later one
  7. green
  8. white
  9. red
  10. orange
  11. an element selector
  12. red
  13. red
  14. orange
  15. orange
  16. blue
  17. orange
  18. blue
  19. blue
  20. blue
  21. green
  22. blue
  23. black
  24. blue
  25. black
  26. red
  27. blue
  28. orange
  29. blue
  30. orange
  31. green
  32. blue
  33. blue
  34. purple
  35. blue
  36. green
  37. red
  38. white
  39. orange
  40. white

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids