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

Answer key

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

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