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

Answer key

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

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