← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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