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