← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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