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