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

Answer key

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

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