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