← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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