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