← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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