← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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