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