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

Answer key

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

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