← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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