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