← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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