← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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