← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 420 · 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 colour is rgb(255, 255, 0)? (a) red (b) cyan (c) bright green (d) yellow
  2. 2.✍️ What is the selector in this CSS rule?
    .box {
      font-size: 20px;
      color: red;
      border: 2px solid;
    }
    (a) red (b) h2 (c) font-size (d) .box
  3. 3.Which of these does CSS do? (a) makes a form box (b) puts a picture on a page (c) gives the page structure (d) adds space around boxes
  4. 4.Which of these does JavaScript do? (a) makes a form box (b) reacts to a button click (c) makes headings and lists (d) makes a link
  5. 5.🎯 Which CSS selector matches this element?
    <h1 class="box" id="intro">Hello</h1>
    (a) .star (b) h2 (c) h1 (d) #box
  6. 6.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  7. 7.🖌️ What colour are the letters?
    h1 {
      text-align: left;
      background-color: green;
      font-size: 20px;
      color: blue;
    }
    (a) green (b) blue (c) yellow
  8. 8.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  9. 9.✍️ What value is given to background-color in this rule?
    .box {
      background-color: yellow;
      margin: 10px;
    }
    (a) yellow (b) 10px (c) 8px (d) background-color
  10. 10.✍️ What value is given to color in this rule?
    .note {
      color: red;
      font-weight: bold;
    }
    (a) color (b) center (c) 20px (d) red
  11. 11.✍️ What value is given to font-style in this rule?
    body {
      font-style: italic;
      width: 300px;
    }
    (a) italic (b) red (c) font-style (d) 20px
  12. 12.✍️ Which property is set to 8px in this rule?
    .note {
      padding: 8px;
      width: 300px;
      font-weight: bold;
    }
    (a) font-weight (b) border (c) 8px (d) padding
  13. 13.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  14. 14.✍️ In color: blue; which part is the value? (a) : (b) color (c) blue (d) ;
  15. 15.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 160px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  16. 16.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) = (d) -
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="star" id="main">Hi</h1>
    CSS:
    #main { color: red; }
    #main { color: orange; }
    (a) red (b) white (c) orange (d) purple
  18. 18.🌈 Which colour is #00ff00? (a) blue (b) red (c) black (d) bright green
  19. 19.🎯 Which CSS selector matches this element?
    <h1 class="note" id="main">Hello</h1>
    (a) #note (b) #logo (c) #main (d) h2
  20. 20.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    .star { color: green; }
    .star { color: black; }
    (a) red (b) blue (c) black (d) green
  21. 21.True or false: padding is space outside the border. (a) True (b) False
  22. 22.✍️ What value is given to background-color in this rule?
    .box {
      background-color: yellow;
      font-size: 20px;
      color: red;
    }
    (a) background-color (b) 10px (c) yellow (d) 8px
  23. 23.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 130px;
      padding: 30px;
      border: 5px solid black;
      margin: 10px;
    }
  24. 24.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
  25. 25.💪 Which flexbox property lines boxes up across? (a) gap (b) align-items (c) flex-direction (d) display: flex
  26. 26.🖌️ Which CSS property picks the font style? (a) color (b) font-family (c) background-color (d) text-align
  27. 27.✍️ What is the selector in this CSS rule?
    .note {
      width: 300px;
      background-color: yellow;
      text-align: center;
      margin: 10px;
    }
    (a) #top (b) yellow (c) width (d) .note
  28. 28.🌈 Which colour is #ff00ff? (a) white (b) black (c) magenta (d) bright green
  29. 29.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 15px;
      border: 2px solid black;
      margin: 15px;
    }
  30. 30.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) justify-content (d) align-items
  31. 31.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 120px;
      padding: 30px;
      border: 4px solid black;
      margin: 5px;
    }
  32. 32.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  33. 33.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
    (a) No (b) Yes
  34. 34.✍️ What value is given to background-color in this rule?
    h1 {
      font-size: 20px;
      color: red;
      background-color: yellow;
    }
    (a) 10px (b) background-color (c) yellow (d) 8px
  35. 35.📦 In the box model, which part is the line round the box? (a) padding (b) content (c) margin (d) border
  36. 36.🎨 Which attribute adds CSS inside one tag? (a) style (b) alt (c) href (d) src
  37. 37.Which of these does JavaScript do? (a) makes headings and lists (b) makes a form box (c) shows a pop-up message (d) adds space around boxes
  38. 38.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
  39. 39.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 130px;
      padding: 20px;
      border: 5px solid black;
      margin: 0px;
    }
  40. 40.What does font-weight do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) picks the font style

Answer key

  1. yellow
  2. .box
  3. adds space around boxes
  4. reacts to a button click
  5. h1
  6. 60
  7. blue
  8. an id selector
  9. yellow
  10. red
  11. italic
  12. padding
  13. 16
  14. blue
  15. 80
  16. :
  17. orange
  18. bright green
  19. #main
  20. black
  21. False
  22. yellow
  23. 220
  24. JavaScript
  25. align-items
  26. font-family
  27. .note
  28. magenta
  29. 344
  30. justify-content
  31. 198
  32. an element selector
  33. No
  34. yellow
  35. border
  36. style
  37. shows a pop-up message
  38. CSS
  39. 180
  40. makes the text bold

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