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