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

Answer key

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

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