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