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

Answer key

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

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