← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 5 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ Which property is set to 20px in this rule?
    .box {
      color: red;
      font-size: 20px;
      background-color: yellow;
      width: 300px;
    }
    (a) 20px (b) font-size (c) background-color (d) text-align
  2. 2.✍️ What value is given to font-style in this rule?
    body {
      background-color: yellow;
      font-style: italic;
    }
    (a) 20px (b) italic (c) red (d) font-style
  3. 3.✍️ What value is given to color in this rule?
    #top {
      font-style: italic;
      color: red;
      font-weight: bold;
      font-size: 20px;
    }
    (a) red (b) 20px (c) center (d) color
  4. 4.✍️ What is the selector in this CSS rule?
    body {
      margin: 10px;
      text-align: center;
      color: red;
    }
    (a) .box (b) center (c) margin (d) body
  5. 5.✍️ What is the selector in this CSS rule?
    h1 {
      font-style: italic;
      font-size: 20px;
    }
    (a) h1 (b) font-style (c) 20px (d) p
  6. 6.✍️ What is the selector in this CSS rule?
    h2 {
      padding: 8px;
      border: 2px solid;
    }
    (a) padding (b) 2px solid (c) h1 (d) h2
  7. 7.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
  8. 8.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      width: 300px;
      background-color: yellow;
    }
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      color: red;
    }
  11. 11.✍️ What value is given to width in this rule?
    h1 {
      color: red;
      width: 300px;
    }
    (a) red (b) 300px (c) italic (d) width
  12. 12.✍️ Which property is set to 10px in this rule?
    li {
      margin: 10px;
      color: red;
    }
    (a) font-weight (b) margin (c) padding (d) 10px
  13. 13.✍️ How does a CSS comment start? (a) <!-- (b) # (c) /* (d) //
  14. 14.✍️ What is the selector in this CSS rule?
    h1 {
      background-color: yellow;
      padding: 8px;
      border: 2px solid;
      margin: 10px;
    }
    (a) p (b) background-color (c) h1 (d) 8px
  15. 15.✍️ What is the selector in this CSS rule?
    h1 {
      padding: 8px;
      font-size: 20px;
    }
    (a) p (b) padding (c) h1 (d) 20px
  16. 16.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      color: red;
      margin: 10px;
      padding: 8px;
    }
  17. 17.✍️ What is the selector in this CSS rule?
    body {
      color: red;
      width: 300px;
      background-color: yellow;
      font-size: 20px;
    }
    (a) 300px (b) body (c) color (d) .box
  18. 18.✍️ What is the selector in this CSS rule?
    h1 {
      text-align: center;
      color: red;
      margin: 10px;
      width: 300px;
    }
    (a) red (b) text-align (c) h1 (d) p
  19. 19.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      border: 2px solid;
      font-size: 20px;
      color: red;
    }
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      color: red;
      font-weight: bold;
    }
  21. 21.✍️ What is the selector in this CSS rule?
    body {
      font-style: italic;
      background-color: yellow;
      border: 2px solid;
    }
    (a) yellow (b) body (c) .box (d) font-style
  22. 22.✍️ What is the selector in this CSS rule?
    h1 {
      background-color: yellow;
      font-style: italic;
      margin: 10px;
    }
    (a) italic (b) h1 (c) background-color (d) p
  23. 23.✍️ What value is given to font-size in this rule?
    body {
      font-size: 20px;
      text-align: center;
    }
    (a) yellow (b) font-size (c) center (d) 20px
  24. 24.✍️ What value is given to border in this rule?
    #top {
      margin: 10px;
      border: 2px solid;
    }
    (a) 300px (b) italic (c) 2px solid (d) border
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      background-color: yellow;
      font-size: 20px;
    }
  26. 26.✍️ In color: blue; which part is the value? (a) color (b) : (c) ; (d) blue
  27. 27.✍️ Which property is set to 10px in this rule?
    h1 {
      border: 2px solid;
      margin: 10px;
      color: red;
    }
    (a) margin (b) 10px (c) padding (d) font-weight
  28. 28.✍️ What is the selector in this CSS rule?
    #top {
      text-align: center;
      padding: 8px;
    }
    (a) 8px (b) text-align (c) #top (d) li
  29. 29.✍️ Which property is set to bold in this rule?
    li {
      text-align: center;
      font-weight: bold;
    }
    (a) border (b) width (c) bold (d) font-weight
  30. 30.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
  31. 31.✍️ What is the selector in this CSS rule?
    li {
      font-weight: bold;
      margin: 10px;
      color: red;
      font-size: 20px;
    }
    (a) font-weight (b) 10px (c) li (d) body
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      background-color: yellow;
      padding: 8px;
      font-weight: bold;
      margin: 10px;
    }
  33. 33.✍️ What value is given to text-align in this rule?
    li {
      text-align: center;
      color: red;
    }
    (a) 10px (b) center (c) text-align (d) yellow
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      font-size: 20px;
      border: 2px solid;
    }
  35. 35.✍️ What is the selector in this CSS rule?
    #top {
      font-size: 20px;
      font-weight: bold;
      width: 300px;
    }
    (a) #top (b) li (c) font-size (d) bold
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      text-align: center;
    }
  37. 37.✍️ What is the selector in this CSS rule?
    p {
      text-align: center;
      font-weight: bold;
      font-style: italic;
    }
    (a) .note (b) bold (c) text-align (d) p
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      border: 2px solid;
      width: 300px;
      text-align: center;
      font-size: 20px;
    }
  39. 39.✍️ What value is given to background-color in this rule?
    #top {
      background-color: yellow;
      text-align: center;
      color: red;
    }
    (a) background-color (b) 8px (c) 10px (d) yellow
  40. 40.✍️ Which property is set to red in this rule?
    p {
      color: red;
      border: 2px solid;
      font-weight: bold;
    }
    (a) text-align (b) color (c) red (d) font-size

Answer key

  1. font-size
  2. italic
  3. red
  4. body
  5. h1
  6. h2
  7. color
  8. :
  9. 2
  10. 1
  11. 300px
  12. margin
  13. /*
  14. h1
  15. h1
  16. 3
  17. body
  18. h1
  19. 3
  20. 2
  21. body
  22. h1
  23. 20px
  24. 2px solid
  25. 2
  26. blue
  27. margin
  28. #top
  29. font-weight
  30. { }
  31. li
  32. 4
  33. center
  34. 2
  35. #top
  36. 1
  37. p
  38. 4
  39. yellow
  40. color

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