← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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