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