← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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