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