← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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