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

Answer key

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

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