← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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