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