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

Answer key

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

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