← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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