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

Answer key

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

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