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

Answer key

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

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