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

Answer key

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

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