← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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