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