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