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