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