← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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