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