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