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

Answer key

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

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