← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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