← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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