← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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