← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 910 · 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.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: yellow; }
    (a) blue (b) black (c) yellow (d) red
  2. 2.True or false: .card is a class selector. (a) True (b) False
  3. 3.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  4. 4.🖌️ How big is the text, in px?
    h2 {
      text-align: left;
      background-color: orange;
      font-size: 16px;
      color: white;
    }
  5. 5.True or false: the content is space outside the border. (a) False (b) True
  6. 6.✍️ What value is given to border in this rule?
    .box {
      font-style: italic;
      font-weight: bold;
      border: 2px solid;
    }
    (a) italic (b) 2px solid (c) border (d) 300px
  7. 7.Which of these is margin? (a) the gap round content (b) the gap to other boxes (c) a solid or dotted edge (d) space inside the border
  8. 8.What does text-align do? (a) picks the font style (b) centres a heading (c) colours behind the text (d) makes the text bold
  9. 9.🧩 Which language gives the page structure? (a) JavaScript (b) HTML (c) CSS
  10. 10.🌈 Which colour is #00ff00? (a) magenta (b) cyan (c) red (d) bright green
  11. 11.🎯 Which element does the selector #end style? (a) <div id="end"> (b) <div class="end"> (c) <span class="red"> (d) <div id="hero">
  12. 12.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: center;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  13. 13.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 230px;
      padding: 20px;
      border: 5px solid black;
      margin: 0px;
    }
  14. 14.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
  15. 15.Which of these does HTML do? (a) sets colours and fonts (b) reacts to a button click (c) makes headings and lists (d) changes the page live
  16. 16.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) black (c) red (d) green
  17. 17.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 22px;
      }
    }
  18. 18.🖌️ Which CSS property sets the letter colour? (a) font-size (b) background-color (c) color (d) text-align
  19. 19.🎨 Which attribute adds CSS inside one tag? (a) href (b) src (c) style (d) alt
  20. 20.✍️ Which property is set to center in this rule?
    .box {
      text-align: center;
      color: red;
    }
    (a) margin (b) background-color (c) text-align (d) center
  21. 21.✍️ What value is given to font-style in this rule?
    h1 {
      font-style: italic;
      border: 2px solid;
      font-size: 20px;
      text-align: center;
    }
    (a) red (b) font-style (c) italic (d) 20px
  22. 22.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 250px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  23. 23.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 24px;
      }
    }
    (a) Yes (b) No
  24. 24.🎨 Which tag connects an outside CSS file? (a) <link> (b) <img> (c) <css> (d) <a>
  25. 25.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 28px;
      }
    }
  26. 26.✍️ What is the selector in this CSS rule?
    .box {
      text-align: center;
      background-color: yellow;
    }
    (a) h2 (b) text-align (c) .box (d) yellow
  27. 27.✍️ What value is given to padding in this rule?
    #top {
      padding: 8px;
      width: 300px;
      border: 2px solid;
      background-color: yellow;
    }
    (a) padding (b) 2px solid (c) 8px (d) bold
  28. 28.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 30px;
      border: 4px solid black;
      margin: 15px;
    }
  29. 29.True or false: margin is space outside the border. (a) True (b) False
  30. 30.🖌️ What colour are the letters?
    p {
      text-align: left;
      font-size: 16px;
      background-color: blue;
      color: red;
    }
    (a) red (b) black (c) blue
  31. 31.🔍 Which is the odd one out? (a) changes the page live (b) reacts to a button click (c) shows a pop-up message (d) rounds box corners
  32. 32.🎯 Which element does the selector #top style? (a) <h1 id="intro"> (b) <h1 id="top"> (c) <h2 class="note"> (d) <h1 class="top">
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    h2 { color: black; }
    .star { color: green; }
    (a) green (b) red (c) black (d) orange
  34. 34.✍️ Which sign goes between a property and its value? (a) = (b) : (c) ; (d) -
  35. 35.🎯 Which CSS selector matches this element?
    <h1 class="red" id="end">Hello</h1>
    (a) #hero (b) .end (c) #end (d) h2
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      color: red;
      border: 2px solid;
      font-style: italic;
      font-size: 20px;
    }
  37. 37.🎯 Which CSS selector matches this element?
    <span class="menu" id="main">Hello</span>
    (a) .menu (b) #menu (c) p (d) .main
  38. 38.What does background-color do? (a) makes the text bold (b) picks the font style (c) sets the letter colour (d) colours behind the text
  39. 39.🧩 Which language sets colours and fonts? (a) HTML (b) JavaScript (c) CSS
  40. 40.🎯 Which CSS selector matches this element?
    <span class="star" id="top">Hello</span>
    (a) .top (b) p (c) #intro (d) #top

Answer key

  1. yellow
  2. True
  3. Yes
  4. 16
  5. False
  6. 2px solid
  7. the gap to other boxes
  8. centres a heading
  9. HTML
  10. bright green
  11. <div id="end">
  12. 20
  13. 280
  14. #
  15. makes headings and lists
  16. red
  17. 22
  18. color
  19. style
  20. text-align
  21. italic
  22. 50
  23. No
  24. <link>
  25. 24
  26. .box
  27. 8px
  28. 258
  29. True
  30. red
  31. rounds box corners
  32. <h1 id="top">
  33. green
  34. :
  35. #end
  36. 4
  37. .menu
  38. colours behind the text
  39. CSS
  40. #top

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