← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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