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