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