← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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