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

Answer key

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

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