← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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