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

Answer key

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

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