← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 656 · 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.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
  2. 2.🎯 Which element does the selector #main style? (a) <div id="main"> (b) <div id="logo"> (c) <span class="red"> (d) <div class="main">
  3. 3.✍️ What is the selector in this CSS rule?
    .box {
      padding: 8px;
      font-style: italic;
      margin: 10px;
      font-weight: bold;
    }
    (a) .box (b) h2 (c) padding (d) italic
  4. 4.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    #end { color: black; }
    p { color: orange; }
    (a) orange (b) black (c) red (d) green
  5. 5.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
  6. 6.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      width: 300px;
      margin: 10px;
    }
    (a) 300px (b) font-weight (c) .note (d) p
  7. 7.🎯 Which element does the selector p style? (a) <h1> (b) <li id="intro"> (c) <p class="menu"> (d) <h2 class="menu">
  8. 8.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
  9. 9.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
  10. 10.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) Z (c) G (d) F
  11. 11.🌈 Which hex code is bright green? (a) #00ff00 (b) #00ffff (c) #ffff00 (d) #000000
  12. 12.✍️ What is the selector in this CSS rule?
    li {
      width: 300px;
      background-color: yellow;
    }
    (a) body (b) width (c) yellow (d) li
  13. 13.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
  14. 14.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-start (c) flex-end (d) center
  15. 15.What does font-size do? (a) centres a heading (b) makes letters bigger (c) colours behind the text (d) sets the letter colour
  16. 16.🌈 Which colour is #ff0000? (a) cyan (b) bright green (c) blue (d) red
  17. 17.✍️ What is the selector in this CSS rule?
    h1 {
      color: red;
      margin: 10px;
      width: 300px;
      font-style: italic;
    }
    (a) color (b) h1 (c) 10px (d) p
  18. 18.What does background-color do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) colours behind the text
  19. 19.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) black (c) white (d) magenta
  20. 20.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) align-items (d) display: flex
  21. 21.📱 Responsive design means a page ___. (a) never changes (b) fits every screen (c) has no pictures (d) is only for laptops
  22. 22.What does text-align do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) makes letters bigger
  23. 23.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 32px;
      }
    }
    (a) Yes (b) No
  24. 24.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the later one (d) the first one
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-style: italic;
    }
  26. 26.🌈 In #070000 the red part is the hex number 07. What is it as a normal number?
  27. 27.🌈 Which colour of light is strongest in rgb(21, 171, 5)? (a) red (b) blue (c) green
  28. 28.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  29. 29.🖌️ Which CSS property makes letters bigger? (a) color (b) background-color (c) font-weight (d) font-size
  30. 30.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 310px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  31. 31.⚖️ What colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    .star { color: red; }
    #hero { color: yellow; }
    (a) red (b) yellow (c) purple (d) blue
  32. 32.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) green (d) white
  33. 33.✍️ What is the selector in this CSS rule?
    body {
      font-style: italic;
      font-size: 20px;
    }
    (a) font-style (b) .box (c) body (d) 20px
  34. 34.🖌️ What colour are the letters?
    p {
      color: green;
      background-color: black;
      text-align: right;
      font-size: 16px;
    }
    (a) black (b) white (c) green
  35. 35.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 25px;
      border: 2px solid black;
      margin: 5px;
    }
  36. 36.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  37. 37.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) ; (d) ,
  38. 38.✍️ What value is given to width in this rule?
    li {
      font-style: italic;
      font-weight: bold;
      width: 300px;
    }
    (a) italic (b) width (c) red (d) 300px
  39. 39.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  40. 40.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 80px;
      padding: 10px;
      border: 3px solid black;
      margin: 5px;
    }

Answer key

  1. /*
  2. <div id="main">
  3. .box
  4. black
  5. HTML
  6. p
  7. <p class="menu">
  8. an element selector
  9. 18
  10. F
  11. #00ff00
  12. li
  13. :
  14. flex-end
  15. makes letters bigger
  16. red
  17. h1
  18. colours behind the text
  19. magenta
  20. flex-direction
  21. fits every screen
  22. centres a heading
  23. Yes
  24. the later one
  25. 1
  26. 7
  27. green
  28. 18
  29. font-size
  30. 10
  31. yellow
  32. blue
  33. body
  34. green
  35. 224
  36. 14
  37. ;
  38. 300px
  39. 24
  40. 116

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