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

Answer key

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

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