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