← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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