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