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