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