Assignment 9 — Understanding the Box Model
Description: | HTML provides padding, margin, and border CSS properties to fine tune the way that elements appear. These elements allow you to indent elements, provide white space around elements, and draw lines around elements. This week, you'll learn about the HTML box model and the difference between the margin, border, and padding properties. The following image from the W3C web site illustrates the box model.
To control space on the page, you have three different properties:
For example, if you wanted to specify 10-pixel padding around a paragraph, you could specify: p {padding: 10px;} You can specify the top, right, bottom, and left, versions of the margin, border, and padding properties separately. For example, if you wanted to specify only a left margin for paragraphs, you could specify: p {margin-left: 10px;} A border allows you to draw lines around the current content. When specifying a border, you need to specify the style of the border (for example, solid or dashed) and the width of the border (usually in pixels). You can specify the width of the line. For example, to draw a 1-pixel border around a paragraph, you could specify: p {border-style: solid; border-width: 1px;} You probably will want to use these properties in different combinations. For example, to include a border above and below a paragraph and to add space between the border and the content of the element, you would use a combination of padding and borders and shown in the following example: p { For more information, see Chapter 9 of the Head First HTML and CSS book. |
||||
CSS properties: |
|
||||
Videos: | Understanding the Box Model | ||||
Tasks: |
|
||||
Grading criteria: | Your assignment should demonstrate:
|
||||
Due: | By 11/13 |
||||
Example assignment: |