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

Answer key

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

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