← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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