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