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