← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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