← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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