1. When you add space between text and a border, you're adding ______.
That's correct. Well done!
The correct answer:
padding
Press Tab or click button to advance to next exercise.
2. Replace one of the zeros to specify 2 ems of padding at the bottom.
padding: 0 0 0 0;
That's correct. Well done!
The correct code:
padding: 0 0 2em 0;
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
3. Re-code this to specify the bottom padding without specifying padding for the other sides.
padding: 0 0 2em 0;
That's correct. Well done!
The correct code:
padding-bottom: 2em;
Press Tab or click button to advance to next exercise.
4. What is the most concise way to specify 1 em of padding for all four sides?
That's correct. Well done!
The correct code:
padding: 1em;
Press Tab or click button to advance to next exercise.
5. Drag-and-drop: Holding down the left mouse button, drag the pieces of code onto the screen to create a class not tied to an element named "boxed" that specifies a border and the same amount of padding all around.
6. Click in the box and type the next character. I'll autocomplete. Don't type spaces or carriage returns. When the exercise is complete, I'll turn the exercise number green.
Style all paragraphs with 1.5ems of padding on the left.
That's correct. Well done!
Press Tab or click button to advance to next exercise.
7. Fail-safe coding. If you type the wrong character, I'll cancel the keystroke. Type spaces. When the exercise is complete, I'll turn the exercise number green.
Create a class of h5 heading named "spacious" that specifies 2 ems of padding all around. Do it the most concise way.
Press Tab or click button to advance to next exercise.
That's correct. Well done!
8. Create a class of paragraphs named "separated" that specifies 3 ems of padding on the bottom. Don't specify padding for any of the other sides.
That's correct. Well done!
The correct code:
p.separated {
padding-bottom: 3em;
}
Press Tab or click button to advance to next exercise.
9. Rewrite this code to create the same specification without specifying the 0-padding sides.
padding: 0 0 0 1em;
That's correct. Well done!
The correct code:
padding-left: 1em;
Press Tab or click button to advance to next exercise.
10. In a single statement specify 1 em padding for top and bottom, 2 em padding for left and right.
That's correct. Well done!
The correct code:
padding: 1em 2em 1em 2em;
Press Tab or click button to advance to next exercise.
11. Create a class not tied to an element that has a solid border all around and 1 em of padding on the left, top, and right. Choose your own border width and color name (not a hex number). Make up a class name.
That's correct. Well done!
Example:
.standout {
border: 3px solid black;
padding: 1em 1em 0 1em;
}
Press Tab or click button to advance to next exercise.
12. Create a class of headings (your choice of size) that specifies a margin (your choice of width) on all four sides and the same amount of padding as margin on all four sides. Make up the class name.
That's correct. Well done!
Example:
h3.special {
margin: 1.2em;
padding: 1.2em;
}
Press Tab or click button to advance to next exercise.
The next several exercises are timed. If you type slowly or dislike time pressure, feel free to increase the allotted time.
13. Time goal: 40 seconds. Create a class of h3 headings named "odd" with top padding of 1 em, and each successive side 1 em of padding more than the side before. Use the concise form of code.
Press Tab or click button to check answer.
The correct code:
h3.odd {
padding: 1em 2em 3em 4em;
}
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
14. Time goal: 35 seconds. Create a class of paragraphs named "separated" that specifies 3 ems of padding on the bottom. Don't specify padding for any of the other sides.
Press Tab or click button to check answer.
The correct code:
p.separated {
padding-bottom: 3em;
}
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
15. Time goal: 20 seconds. Rewrite this code to create the same specification without specifying the 0-padding sides.
padding: 0 0 0 1em;
Press Tab or click button to check answer.
The correct code:
padding-left: 1em;
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
16. Time goal: 25 seconds. In a single statement specify 1 em padding for top and bottom, 2 em padding for left and right.
Press Tab or click button to check answer.
The correct code:
padding: 1em 2em 1em 2em;
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
17. Time goal: 70 seconds. Create a class not tied to an element that has a solid border all around and 1 em of padding on the left, top, and right. Choose your own border width and color name (not a hex number). Make up a class name.
Press Tab or click button to check answer.
Example:
.standout {
border: 3px solid black;
padding: 1em 1em 0 1em;
}
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
18. Time goal: 50 seconds. Create a class of headings (your choice of size) that specifies a margin (your choice of width) on all four sides and the same amount of padding as margin on all four sides. Make up the class name.
Press Tab or click button to check answer.
Example:
h3.special {
margin: 1.2em;
padding: 1.2em;
}
Press Tab or click button to advance to next exercise.
Press Tab or click button to advance to next exercise.
19. Access this live coding exercise at JS Fiddle. When you've completed the exercise, close the JS Fiddle window, and you'll be returned to this page. (If JS Fiddle displays a warning message saying that your changes will be reset, click Leave this Page.)
Click button to advance.
20. Access this live coding exercise at JS Fiddle. When you've completed the exercise, close the JS Fiddle window, and you'll be returned to this page. (If JS Fiddle displays a warning message saying that your changes will be reset, click Leave this Page.)
Click button to advance.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
1
0