← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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