← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 241 · 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?
    <h1 class="menu" id="hero">Hi</h1>
    CSS:
    .menu { color: yellow; }
    #hero { color: orange; }
    (a) yellow (b) red (c) blue (d) orange
  2. 2.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 260px;
      padding: 25px;
      border: 3px solid black;
      margin: 10px;
    }
  3. 3.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 180px;
      padding: 15px;
      border: 5px solid black;
      margin: 5px;
    }
  4. 4.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
  5. 5.True or false: the border is space outside the border. (a) True (b) False
  6. 6.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 450px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  7. 7.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 32px;
      }
    }
  8. 8.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) ; (d) :
  9. 9.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 8px;
      }
    }
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-size: 20px;
      padding: 8px;
    }
  11. 11.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    #top { color: purple; }
    #top { color: blue; }
    (a) purple (b) yellow (c) white (d) blue
  13. 13.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 240px;
      padding: 25px;
      border: 5px solid black;
      margin: 0px;
    }
  14. 14.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 16px;
      }
    }
  15. 15.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 110px;
      padding: 10px;
      border: 3px solid black;
      margin: 15px;
    }
  16. 16.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) red (d) green
  17. 17.🖌️ How big is the text, in px?
    p {
      text-align: center;
      color: green;
      background-color: orange;
      font-size: 16px;
    }
  18. 18.📱 What does a media query check? (a) the page title (b) the time of day (c) the battery level (d) the screen width
  19. 19.🌈 Which hex code is cyan? (a) #000000 (b) #00ffff (c) #ff00ff (d) #0000ff
  20. 20.🖌️ How big is the text, in px?
    h1 {
      background-color: green;
      text-align: right;
      font-size: 24px;
      color: purple;
    }
  21. 21.✍️ CSS declarations go inside which brackets? (a) [ ] (b) ( ) (c) < > (d) { }
  22. 22.🎯 Which element does the selector h1 style? (a) <h2> (b) <li class="note"> (c) <div id="end"> (d) <h1 class="note">
  23. 23.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 32px;
      }
    }
  24. 24.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 90px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  25. 25.🖌️ Which CSS property colours behind the text? (a) font-family (b) text-align (c) color (d) background-color
  26. 26.✍️ In color: blue; which part is the value? (a) blue (b) ; (c) : (d) color
  27. 27.🌈 In #000016 the blue part is the hex number 16. What is it as a normal number?
  28. 28.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 220px;
      padding: 5px;
      border: 4px solid black;
      margin: 5px;
    }
  29. 29.🖌️ Where does the text sit on its line?
    h1 {
      color: blue;
      background-color: yellow;
      text-align: center;
      font-size: 24px;
    }
    (a) on the left (b) on the right (c) in the middle
  30. 30.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
  31. 31.What does font-size do? (a) picks the font style (b) colours behind the text (c) makes letters bigger (d) centres a heading
  32. 32.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  33. 33.📦 In the box model, which part is space inside the border? (a) padding (b) border (c) margin (d) content
  34. 34.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
  35. 35.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
  36. 36.🔍 Which is the odd one out? (a) counts down a timer (b) checks a quiz answer (c) reacts to a button click (d) sets colours and fonts
  37. 37.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  38. 38.True or false: .big is a class selector. (a) False (b) True
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="star" id="end">Hi</h2>
    CSS:
    .star { color: red; }
    .star { color: purple; }
    (a) black (b) red (c) purple (d) white
  40. 40.🎨 Which tag holds CSS inside the head? (a) <body> (b) <css> (c) <style> (d) <script>

Answer key

  1. orange
  2. 336
  3. 220
  4. an element selector
  5. False
  6. 70
  7. 24
  8. ;
  9. 8
  10. 2
  11. Yes
  12. blue
  13. 300
  14. 12
  15. 166
  16. blue
  17. 16
  18. the screen width
  19. #00ffff
  20. 24
  21. { }
  22. <h1 class="note">
  23. 24
  24. 10
  25. background-color
  26. blue
  27. 22
  28. 238
  29. in the middle
  30. an id selector
  31. makes letters bigger
  32. 30
  33. padding
  34. CSS
  35. 3
  36. sets colours and fonts
  37. No
  38. True
  39. purple
  40. <style>

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