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

Answer key

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

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