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

Answer key

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

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