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