← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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