← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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