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

Answer key

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

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