← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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