← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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