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