← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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