← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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