← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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