← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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