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

Answer key

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

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