← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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