← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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