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