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