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