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