← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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