← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 836 · 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.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 28px;
      }
    }
    (a) No (b) Yes
  2. 2.Which of these is padding? (a) space inside the border (b) the line round the box (c) a solid or dotted edge (d) the gap to other boxes
  3. 3.✍️ Which sign goes between a property and its value? (a) : (b) ; (c) - (d) =
  4. 4.Which of these does HTML do? (a) puts a picture on a page (b) changes the page live (c) changes the text size (d) lays out the page
  5. 5.⚖️ What colour is the text of this element?
    <p class="star" id="end">Hi</p>
    CSS:
    .star { color: white; }
    p { color: yellow; }
    (a) yellow (b) white (c) green (d) black
  6. 6.True or false: CSS changes the text size. (a) False (b) True
  7. 7.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    #end { color: blue; }
    #end { color: red; }
    (a) yellow (b) red (c) blue (d) black
  8. 8.✍️ CSS declarations go inside which brackets? (a) { } (b) ( ) (c) < > (d) [ ]
  9. 9.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  10. 10.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  11. 11.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    .menu { color: green; }
    .menu { color: blue; }
    (a) black (b) blue (c) purple (d) green
  12. 12.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
  13. 13.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      color: red;
      background-color: yellow;
      margin: 10px;
    }
  14. 14.🖌️ Which CSS property makes the text bold? (a) background-color (b) font-weight (c) font-family (d) text-align
  15. 15.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
  16. 16.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 4 (d) 3
  17. 17.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 120px;
      padding: 10px;
      border: 1px solid black;
      margin: 20px;
    }
  18. 18.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    .note { color: blue; }
    p { color: green; }
    #hero { color: white; }
    (a) blue (b) green (c) red (d) white
  19. 19.✍️ What is the selector in this CSS rule?
    p {
      font-size: 20px;
      border: 2px solid;
      width: 300px;
    }
    (a) 2px solid (b) p (c) .note (d) font-size
  20. 20.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
  21. 21.True or false: padding is space inside the border. (a) True (b) False
  22. 22.🌈 Which hex code is bright green? (a) #ffffff (b) #ffff00 (c) #00ff00 (d) #0000ff
  23. 23.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
  24. 24.True or false: #end is an id selector. (a) True (b) False
  25. 25.✍️ What value is given to font-style in this rule?
    #top {
      background-color: yellow;
      font-weight: bold;
      font-style: italic;
    }
    (a) 20px (b) italic (c) font-style (d) red
  26. 26.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 70px;
      padding: 20px;
      border: 3px solid black;
      margin: 0px;
    }
  27. 27.🎯 Which element does the selector #intro style? (a) <li class="intro"> (b) <li id="intro"> (c) <li id="main"> (d) <div class="menu">
  28. 28.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      color: red;
      background-color: yellow;
    }
  29. 29.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 250px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  30. 30.✍️ What value is given to color in this rule?
    h1 {
      color: red;
      margin: 10px;
      background-color: yellow;
      border: 2px solid;
    }
    (a) 20px (b) red (c) center (d) color
  31. 31.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    #main { color: blue; }
    .red { color: green; }
    (a) green (b) black (c) yellow (d) blue
  32. 32.True or false: the content is the text or picture. (a) False (b) True
  33. 33.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) ; (d) :
  34. 34.True or false: JavaScript makes a link. (a) False (b) True
  35. 35.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    .red { color: green; }
    p { color: blue; }
    #logo { color: orange; }
    (a) red (b) blue (c) orange (d) green
  36. 36.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  37. 37.✍️ What is the selector in this CSS rule?
    .note {
      font-weight: bold;
      text-align: center;
    }
    (a) center (b) #top (c) .note (d) font-weight
  38. 38.🌈 Which colour is #ff00ff? (a) magenta (b) white (c) black (d) yellow
  39. 39.What does justify-content: flex-start 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
  40. 40.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) green (d) white

Answer key

  1. No
  2. space inside the border
  3. :
  4. puts a picture on a page
  5. white
  6. True
  7. red
  8. { }
  9. 22
  10. No
  11. blue
  12. an id selector
  13. 3
  14. font-weight
  15. an id selector
  16. 3
  17. 182
  18. white
  19. p
  20. packs boxes at the end
  21. True
  22. #00ff00
  23. 10
  24. True
  25. italic
  26. 116
  27. <li id="intro">
  28. 2
  29. 10
  30. red
  31. blue
  32. True
  33. ;
  34. False
  35. orange
  36. 16
  37. .note
  38. magenta
  39. packs boxes at the start
  40. blue

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