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