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