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