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