← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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