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