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