← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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