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

Answer key

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

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