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

Answer key

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

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