← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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