← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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