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