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