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