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