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