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