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