← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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