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