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