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