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