← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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