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