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