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