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