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