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