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