← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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