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

Answer key

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

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