← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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