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

Answer key

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

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