← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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