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