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