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