← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 67 · 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="note" id="logo">Hi</h1>
    CSS:
    h1 { color: black; }
    h1 { color: red; }
    (a) white (b) yellow (c) black (d) red
  2. 2.🎯 Which element does the selector p style? (a) <p class="box"> (b) <li id="logo"> (c) <h2 class="box"> (d) <h1>
  3. 3.🌈 Which colour of light is strongest in rgb(113, 173, 128)? (a) red (b) blue (c) green
  4. 4.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 80px;
      padding: 25px;
      border: 1px solid black;
      margin: 10px;
    }
  5. 5.🎯 What kind of selector is #logo? (a) a class selector (b) an element selector (c) an id selector
  6. 6.🌈 Which hex code is white? (a) #00ffff (b) #ffffff (c) #ff00ff (d) #ff0000
  7. 7.True or false: CSS lays out the page. (a) False (b) True
  8. 8.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) J (c) G (d) Z
  9. 9.🌈 In #5a0000 the red part is the hex number 5a. What is it as a normal number?
  10. 10.📦 In the box model, which part is space outside the border? (a) content (b) padding (c) margin (d) border
  11. 11.⚖️ 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
  12. 12.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 270px;
      padding: 10px;
      border: 3px solid black;
      margin: 5px;
    }
  13. 13.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 180px;
      padding: 10px;
      border: 2px solid black;
      margin: 5px;
    }
  14. 14.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    #main { color: purple; }
    p { color: red; }
    (a) red (b) white (c) black (d) purple
  15. 15.True or false: margin is space outside the border. (a) True (b) False
  16. 16.✍️ What value is given to border in this rule?
    p {
      width: 300px;
      border: 2px solid;
    }
    (a) italic (b) 300px (c) border (d) 2px solid
  17. 17.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    .red { color: purple; }
    #intro { color: blue; }
    p { color: red; }
    (a) red (b) blue (c) purple (d) orange
  18. 18.🖌️ Where does the text sit on its line?
    h2 {
      color: green;
      background-color: red;
      text-align: center;
      font-size: 24px;
    }
    (a) on the left (b) on the right (c) in the middle
  19. 19.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) : (d) =
  20. 20.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  21. 21.🖌️ What colour are the letters?
    li {
      background-color: purple;
      font-size: 12px;
      text-align: center;
      color: orange;
    }
    (a) purple (b) blue (c) orange
  22. 22.🎯 Which CSS selector matches this element?
    <p class="star" id="end">Hello</p>
    (a) #star (b) p (c) .end (d) h1
  23. 23.🎯 What kind of selector is h1? (a) an id selector (b) a class selector (c) an element selector
  24. 24.What does text-align do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes the text bold
  25. 25.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 190px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  26. 26.🔍 Which is the odd one out? (a) changes the page live (b) changes the text size (c) reacts to a button click (d) checks a quiz answer
  27. 27.✍️ What is the selector in this CSS rule?
    h2 {
      font-weight: bold;
      text-align: center;
    }
    (a) h1 (b) h2 (c) font-weight (d) center
  28. 28.🔍 Which is the odd one out? (a) rounds box corners (b) makes headings and lists (c) gives the page structure (d) puts a picture on a page
  29. 29.🌈 Which colour is #ff00ff? (a) black (b) yellow (c) white (d) magenta
  30. 30.🌈 Which hex code is magenta? (a) #00ffff (b) #ffffff (c) #000000 (d) #ff00ff
  31. 31.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
  32. 32.🔍 Which is the odd one out? (a) sets colours and fonts (b) makes headings and lists (c) gives the page structure (d) makes a form box
  33. 33.🌈 Which colour is rgb(255, 255, 0)? (a) cyan (b) red (c) yellow (d) bright green
  34. 34.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 24px;
      }
    }
    (a) Yes (b) No
  35. 35.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    .star { color: green; }
    h1 { color: white; }
    #end { color: black; }
    (a) green (b) white (c) black (d) red
  36. 36.True or false: .big is a class selector. (a) False (b) True
  37. 37.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) . (d) ;
  38. 38.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 40px;
      padding: 25px;
      border: 5px solid black;
      margin: 5px;
    }
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="box" id="intro">Hi</h2>
    CSS:
    #intro { color: white; }
    h2 { color: black; }
    (a) green (b) white (c) yellow (d) black
  40. 40.What does font-size do? (a) makes letters bigger (b) picks the font style (c) makes the text bold (d) centres a heading

Answer key

  1. red
  2. <p class="box">
  3. green
  4. 152
  5. an id selector
  6. #ffffff
  7. True
  8. F
  9. 90
  10. margin
  11. the later one
  12. 306
  13. 214
  14. purple
  15. True
  16. 2px solid
  17. blue
  18. in the middle
  19. :
  20. 10
  21. orange
  22. p
  23. an element selector
  24. centres a heading
  25. 10
  26. changes the text size
  27. h2
  28. rounds box corners
  29. magenta
  30. #ff00ff
  31. a class selector
  32. sets colours and fonts
  33. yellow
  34. No
  35. black
  36. True
  37. ;
  38. 110
  39. white
  40. makes letters bigger

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