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

Answer key

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

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