← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 282 · 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 CSS property picks the font style? (a) font-family (b) text-align (c) background-color (d) font-size
  2. 2.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) G (c) J (d) F
  3. 3.🖌️ How big is the text, in px?
    h2 {
      background-color: blue;
      font-size: 16px;
      color: white;
      text-align: left;
    }
  4. 4.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 50px;
      padding: 15px;
      border: 1px solid black;
      margin: 10px;
    }
  5. 5.🌈 In #8e0000 the red part is the hex number 8e. What is it as a normal number?
  6. 6.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 16px;
      }
    }
  7. 7.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 80px;
      padding: 20px;
      border: 4px solid black;
      margin: 5px;
    }
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="red" id="end">Hi</h1>
    CSS:
    h1 { color: orange; }
    h1 { color: black; }
    (a) black (b) orange (c) blue (d) purple
  9. 9.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 150px;
      padding: 10px;
      border: 2px solid black;
      margin: 20px;
    }
  10. 10.Which of these does JavaScript do? (a) checks a quiz answer (b) makes a form box (c) makes headings and lists (d) gives the page structure
  11. 11.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) red (d) blue
  12. 12.⚖️ What colour is the text of this element?
    <h2 class="menu" id="main">Hi</h2>
    CSS:
    h2 { color: yellow; }
    h2 { color: black; }
    (a) white (b) black (c) green (d) yellow
  13. 13.✍️ What value is given to background-color in this rule?
    h1 {
      margin: 10px;
      background-color: yellow;
    }
    (a) 10px (b) background-color (c) yellow (d) 8px
  14. 14.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
  15. 15.✍️ What is the selector in this CSS rule?
    body {
      padding: 8px;
      color: red;
    }
    (a) red (b) .box (c) body (d) padding
  16. 16.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  17. 17.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <css> (d) <script>
  18. 18.🎯 Which CSS selector matches this element?
    <h1 class="note" id="hero">Hello</h1>
    (a) .hero (b) h1 (c) #top (d) h2
  19. 19.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 255 (c) 100 (d) 1000
  20. 20.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 26px;
      }
    }
    (a) Yes (b) No
  21. 21.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  22. 22.True or false: the border is the line round the box. (a) False (b) True
  23. 23.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) flex-start (c) space-between (d) center
  24. 24.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 24px;
      }
    }
  25. 25.True or false: #main is an element selector. (a) True (b) False
  26. 26.What does text-align do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) colours behind the text
  27. 27.🖌️ What colour is behind the letters?
    li {
      background-color: blue;
      color: green;
      text-align: right;
      font-size: 12px;
    }
    (a) green (b) blue (c) red
  28. 28.⚖️ What colour is the text of this element?
    <h1 class="note" id="end">Hi</h1>
    CSS:
    .note { color: black; }
    h1 { color: blue; }
    (a) red (b) white (c) black (d) blue
  29. 29.True or false: img is an id selector. (a) True (b) False
  30. 30.Which of these is the content? (a) the text or picture (b) space outside the border (c) a solid or dotted edge (d) the gap to other boxes
  31. 31.✍️ What value is given to width in this rule?
    h2 {
      width: 300px;
      margin: 10px;
    }
    (a) italic (b) red (c) 300px (d) width
  32. 32.True or false: #top is an id selector. (a) False (b) True
  33. 33.🎯 Which element does the selector #main style? (a) <p class="main"> (b) <p id="logo"> (c) <h1 class="star"> (d) <p id="main">
  34. 34.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    .box { color: orange; }
    #main { color: purple; }
    (a) orange (b) black (c) yellow (d) purple
  35. 35.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 130px;
      padding: 15px;
      border: 1px solid black;
      margin: 0px;
    }
  36. 36.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
  37. 37.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
  38. 38.🎨 One CSS file can style how many pages? (a) only one word (b) no pages (c) only one image (d) many pages
  39. 39.🖌️ What colour are the letters?
    h2 {
      font-size: 24px;
      background-color: yellow;
      color: white;
      text-align: left;
    }
    (a) white (b) orange (c) yellow
  40. 40.🌈 In #8d0000 the red part is the hex number 8d. What is it as a normal number?

Answer key

  1. font-family
  2. F
  3. 16
  4. 102
  5. 142
  6. 12
  7. 128
  8. black
  9. 214
  10. checks a quiz answer
  11. red
  12. black
  13. yellow
  14. puts boxes in the middle
  15. body
  16. 40
  17. <style>
  18. h1
  19. 255
  20. No
  21. an id selector
  22. True
  23. center
  24. 24
  25. False
  26. centres a heading
  27. blue
  28. black
  29. False
  30. the text or picture
  31. 300px
  32. True
  33. <p id="main">
  34. purple
  35. 162
  36. fits every screen
  37. the later one
  38. many pages
  39. white
  40. 141

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