← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 358 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.✍️ Which property is set to center in this rule?
    h1 {
      text-align: center;
      font-style: italic;
      color: red;
      font-weight: bold;
    }
    (a) text-align (b) background-color (c) center (d) margin
  2. 2.⚖️ What colour is the text of this element?
    <h1 class="red" id="main">Hi</h1>
    CSS:
    .red { color: purple; }
    #main { color: yellow; }
    h1 { color: red; }
    (a) yellow (b) white (c) red (d) purple
  3. 3.🎯 Which element does the selector div style? (a) <h1 id="main"> (b) <p class="big"> (c) <div class="big"> (d) <span>
  4. 4.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) has no pictures (d) fits every screen
  5. 5.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 14px;
      }
    }
  6. 6.🔍 Which is the odd one out? (a) rounds box corners (b) adds space around boxes (c) changes the text size (d) changes the page live
  7. 7.🌈 In #00bd00 the green part is the hex number bd. What is it as a normal number?
  8. 8.True or false: p is an id selector. (a) True (b) False
  9. 9.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  10. 10.📦 In the box model, which part is the gap round content? (a) content (b) padding (c) border (d) margin
  11. 11.✍️ In color: blue; which part is the property? (a) blue (b) : (c) ; (d) color
  12. 12.True or false: JavaScript shows a pop-up message. (a) False (b) True
  13. 13.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      color: red;
      margin: 10px;
      font-size: 20px;
      padding: 8px;
    }
  14. 14.What does justify-content: flex-end do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
  15. 15.🎯 Can many elements share the same class? (a) No (b) Yes
  16. 16.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 120px;
      padding: 30px;
      border: 4px solid black;
      margin: 0px;
    }
  17. 17.🎨 Which attribute adds CSS inside one tag? (a) href (b) style (c) alt (d) src
  18. 18.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) black (d) blue
  19. 19.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
  20. 20.🎯 Which CSS selector matches this element?
    <h1 class="box" id="end">Hello</h1>
    (a) .star (b) h2 (c) .end (d) .box
  21. 21.✍️ What value is given to border in this rule?
    h1 {
      color: red;
      border: 2px solid;
      font-size: 20px;
      margin: 10px;
    }
    (a) italic (b) 2px solid (c) 300px (d) border
  22. 22.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 240px;
      padding: 25px;
      border: 5px solid black;
      margin: 0px;
    }
  23. 23.⚖️ What colour is the text of this element?
    <h1 class="menu" id="end">Hi</h1>
    CSS:
    .menu { color: red; }
    .menu { color: green; }
    (a) orange (b) red (c) black (d) green
  24. 24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
  25. 25.🖌️ Where does the text sit on its line?
    h2 {
      text-align: right;
      background-color: blue;
      font-size: 24px;
      color: black;
    }
    (a) in the middle (b) on the right (c) on the left
  26. 26.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 1000 (c) 255 (d) 100
  27. 27.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) reacts to a button click (d) makes headings and lists
  28. 28.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 200px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  29. 29.True or false: the border is a solid or dotted edge. (a) True (b) False
  30. 30.Which of these does CSS do? (a) reacts to a button click (b) lays out the page (c) makes headings and lists (d) shows a pop-up message
  31. 31.✍️ What is the selector in this CSS rule?
    #top {
      color: red;
      border: 2px solid;
      font-weight: bold;
    }
    (a) #top (b) 2px solid (c) li (d) color
  32. 32.True or false: the border is the line round the box. (a) False (b) True
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: green; }
    .star { color: orange; }
    (a) red (b) blue (c) green (d) orange
  34. 34.🎯 Which CSS selector matches this element?
    <span class="menu" id="intro">Hello</span>
    (a) #main (b) .menu (c) #menu (d) .note
  35. 35.🖌️ What colour are the letters?
    h1 {
      background-color: yellow;
      font-size: 28px;
      text-align: center;
      color: black;
    }
    (a) white (b) yellow (c) black
  36. 36.✍️ What is the selector in this CSS rule?
    p {
      border: 2px solid;
      font-style: italic;
      color: red;
    }
    (a) italic (b) border (c) p (d) .note
  37. 37.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      text-align: center;
      font-style: italic;
      font-weight: bold;
      border: 2px solid;
    }
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    #end { color: red; }
    .box { color: yellow; }
    (a) yellow (b) blue (c) green (d) red
  40. 40.🎯 What kind of selector is #logo? (a) a class selector (b) an element selector (c) an id selector

Answer key

  1. text-align
  2. yellow
  3. <div class="big">
  4. fits every screen
  5. 16
  6. changes the page live
  7. 189
  8. False
  9. No
  10. padding
  11. color
  12. True
  13. 4
  14. packs boxes at the end
  15. Yes
  16. 188
  17. style
  18. red
  19. an element selector
  20. .box
  21. 2px solid
  22. 300
  23. green
  24. 22
  25. on the right
  26. 255
  27. reacts to a button click
  28. 20
  29. True
  30. lays out the page
  31. #top
  32. True
  33. orange
  34. .menu
  35. black
  36. p
  37. ;
  38. 4
  39. red
  40. an id selector

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