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