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

Answer key

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

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