← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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