← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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