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

Answer key

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

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