← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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