← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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