← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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