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

Answer key

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

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