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

Answer key

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

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