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

Answer key

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

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