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