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