← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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