← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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