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