← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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