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