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

Answer key

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

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