UNDER CONSTRUCTION

I am currently re-writing this page: use the refresh button in your browser to see if it's finished, yet.

Week 9: Box Model, Text/Fonts

In this lesson you'll learn about the CSS Box Model, which allows you to add borders and spacing in/around elements. You'll also learn a few of the more common properties used to customize text and fonts.

Box Model

Notes

Text/Fonts

Notes

Resources

Homework

Practice/Study Questions

Practice Exercises

Note
In the practice exercises, elements are referred to in all-caps, e.g. FOOTER refers to the <footer></footer> element (or it could also refer to an opening <footer> tag or closing </footer> tag, you will know by the context in which it's used).

For each exercise, validate the HTML using the HTML Validator. Fix all problems until you get no errors.

  1. If you haven't already done so, create a sub-directory in your local workspace and in your server workspace (off /syst10049) called "week9". Feel free to add an extra level for all of your practice exercises (e.g. /exercises).
    • For each practice exercise in each lesson, you'll usually be asked to create an exercise directory for that project, such as "/exercise1".
    • It is assumed that you will create the exercise project directory in both your local workspace and in your server workspace using the appropriate and standard directory structure discussed in class.
  2. Create a new project directory called exercise1. Create an index page. Add a /css directory and add a CSS file to it. Add the <link> element in your index page to the css file.

    Copy the HTML from the codepen for Week 9 Exercise 1 and paste it into the body of your index page.

    Copy the small amount of CSS from the CodePen's CSS tab into your css file.

    All measurements should use relative units, unless specified otherwise.

    In the CSS file, add the following styling (note that when a portion "of the font size" or "of the base font size" is referenced, it's referring to the document's base font size unless it says otherwise):

    • The header element should have a background colour of your choice and a margin that is half the base font size on top/bottom and 100% of the base font size on the right/left. There should also be padding inside the element around its child elements that is half the base font size.
    • The footer element should have the same background, border, margin, and padding as the header.
    • Article elements should have the same margin and padding as the header and footer elements.
    • All level-1 and level-2 headings should be in "title case".
    • Level 1 headings should have a top and bottom border (you choose the style, thickness and colour).
    • Level 2 headings should have a thin dashed, bottom border in whatever colour you like.
    • The navigation elements should have a margin of .3 of the base font size on all sides and .25 of the base font size for padding on all sides. The items inside the nav elements should be centered.
    • The links that are inside navigation elements should have no underline, and they should look like buttons. Tip: to style only links inside a nav, use the selector nav a
  3. Create a new project directory called /exercise2. Add an HTML index page and give it the minimal HTML. In the body of the document, paste the HTML from this CodePen. Add an external CSS file and in an appropriate directory and link to it in your HTML. Add the following styles to your CSS:
    • The table element should have a solid border that is .2em, in green (#388E3C), and a margin on all sides that is half the base font.
    • The table caption's text should be bold, 1.2 times the base font size, and have a light green background (#E8F5E9).
    • All table cells should have a .1em solid border in green (#388E3C). They should also have inner spacing that is .2 times the base font size.