← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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