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