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

Answer key

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

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