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

Answer key

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

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