← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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