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

Answer key

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

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