← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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