← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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