Lesson 2: Applying the Box Model in CSS
In the previous lesson you learned about the layers that form a "box" in the CSS box model, namely padding, border, and margin. In the current lesson, you will have the opportunity to apply what you learned to your web portfolio.
At the completion of this exercise:
- you will be able to add margins, borders, and paddings to HTML elements using CSS.
- Open your web portfolio's external style sheet in a text editor, and its home page in a browser.
- If you haven't already added a margin to your body in previous lessons, do so now. Set both the margin-left and margin-right properties to 10%.
- Add padding, border, margin, color, background-color, and width properties to the following elements:
- Play with a variety of properties using the W3School CSS Reference as a guide.
- If you're using a current browser, try some of the especially cool CSS3 properties, such as border-radius and box-shadow.
- Each time you add or change a property, save the file and refresh your browser to see what effect the change had on your home page.
- When you are satisfied with the new look of your home page, open the file accessibility.html, which you created in the lesson on Creating a Data Table. Currently your data table probably doesn't look very interesting. Try adding style definitions to your style sheet that effect the way the table is displayed. You can stylize all of the elements that comprise the table (including table, th, td, and caption. Each of these elements is a box, so you can change the way it looks by playing with the padding, border, and margin properties for each of these elements.
After you are satisfied with the new look of your website, especially index.html and accessibility.html, show these pages to your instructor before proceeding to the next module.