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