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