← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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