← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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