← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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