← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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