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

Answer key

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

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