← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 27 · 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 tag helps phones show a page at the right size? (a) the br tag (b) the hr tag (c) the title tag (d) the viewport meta tag
  2. 2.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) alt (d) style
  3. 3.🌈 Which hex code is red? (a) #00ff00 (b) #0000ff (c) #ff00ff (d) #ff0000
  4. 4.✍️ What value is given to font-weight in this rule?
    #top {
      width: 300px;
      font-weight: bold;
      background-color: yellow;
    }
    (a) font-weight (b) 300px (c) 2px solid (d) bold
  5. 5.🌈 In #0000fd the blue part is the hex number fd. What is it as a normal number?
  6. 6.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  7. 7.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
    (a) Yes (b) No
  8. 8.🌈 Which colour is rgb(255, 0, 0)? (a) red (b) cyan (c) black (d) white
  9. 9.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  10. 10.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 240px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  11. 11.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    p { color: black; }
    p { color: yellow; }
    (a) blue (b) white (c) black (d) yellow
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      text-align: center;
      border: 2px solid;
    }
  13. 13.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: orange; }
    .red { color: yellow; }
    (a) yellow (b) blue (c) purple (d) orange
  14. 14.🖌️ Which CSS property sets the letter colour? (a) text-align (b) background-color (c) color (d) font-weight
  15. 15.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) flex-direction (d) align-items
  16. 16.True or false: .star is a class selector. (a) True (b) False
  17. 17.✍️ What value is given to border in this rule?
    h2 {
      border: 2px solid;
      background-color: yellow;
    }
    (a) 300px (b) border (c) italic (d) 2px solid
  18. 18.💪 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).
  19. 19.✍️ Which property is set to 2px solid in this rule?
    h1 {
      border: 2px solid;
      width: 300px;
      margin: 10px;
    }
    (a) width (b) font-style (c) border (d) 2px solid
  20. 20.What does justify-content: flex-start do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
  21. 21.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  22. 22.🖌️ What colour is behind the letters?
    h1 {
      text-align: left;
      background-color: red;
      font-size: 28px;
      color: blue;
    }
    (a) yellow (b) red (c) blue
  23. 23.📦 In the box model, which part is space inside the border? (a) border (b) padding (c) content (d) margin
  24. 24.🧩 Which language adds space around boxes? (a) CSS (b) HTML (c) JavaScript
  25. 25.What does justify-content: space-between do? (a) packs boxes at the end (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the start
  26. 26.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 14px;
      }
    }
    (a) Yes (b) No
  27. 27.✍️ What is the selector in this CSS rule?
    p {
      padding: 8px;
      font-size: 20px;
      border: 2px solid;
      font-style: italic;
    }
    (a) padding (b) 20px (c) .note (d) p
  28. 28.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      text-align: center;
      font-weight: bold;
      border: 2px solid;
      background-color: yellow;
    }
  29. 29.True or false: margin is space outside the border. (a) False (b) True
  30. 30.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) content (d) margin
  31. 31.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 220px;
      padding: 10px;
      border: 1px solid black;
      margin: 15px;
    }
  32. 32.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) align-items (c) display: flex (d) gap
  33. 33.✍️ What is the selector in this CSS rule?
    .note {
      font-size: 20px;
      text-align: center;
      width: 300px;
      padding: 8px;
    }
    (a) font-size (b) center (c) #top (d) .note
  34. 34.🖌️ What colour are the letters?
    h1 {
      background-color: green;
      color: orange;
      font-size: 32px;
      text-align: right;
    }
    (a) green (b) blue (c) orange
  35. 35.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
  36. 36.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
  37. 37.True or false: the content is the text or picture. (a) True (b) False
  38. 38.📱 What does a media query check? (a) the screen width (b) the page title (c) the battery level (d) the time of day
  39. 39.⚖️ What colour is the text of this element?
    <h1 class="box" id="main">Hi</h1>
    CSS:
    h1 { color: black; }
    h1 { color: blue; }
    (a) black (b) orange (c) red (d) blue
  40. 40.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    #top { color: blue; }
    #top { color: white; }
    (a) blue (b) black (c) white (d) red

Answer key

  1. the viewport meta tag
  2. style
  3. #ff0000
  4. bold
  5. 253
  6. 20
  7. Yes
  8. red
  9. Yes
  10. 60
  11. yellow
  12. 2
  13. yellow
  14. color
  15. align-items
  16. True
  17. 2px solid
  18. 60
  19. border
  20. packs boxes at the start
  21. 40
  22. red
  23. padding
  24. CSS
  25. equal gaps, none at ends
  26. Yes
  27. p
  28. 4
  29. True
  30. margin
  31. 272
  32. display: flex
  33. .note
  34. orange
  35. 16
  36. JavaScript
  37. True
  38. the screen width
  39. blue
  40. white

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