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