Skip to content
Apr 21 10

CSS Background Image Replacement Tutorial

by Brad

In this CSS Video Tutorial we learn how to replace plain text elements with CSS background images.  This is a great strategy to improve your SEO (search engine optimization) performance, and also increase accessibility.

Apr 14 10

CSS Navigation Tutorial

by Brad

In this CSS Video Tutorial we learn how to apply very basic styles (including hover effects) to our navigation. For quick reference, you may also watch the tutorial where we created the Two Column Layout.

Apr 13 10

Equal Height Columns – CSS Tutorial

by Brad

In this CSS Video Tutorial we learn how to create equal height column backgrounds.

Apr 12 10

CSS Two Column Layout Tutorial

by Brad

In this CSS tutorial we learn how to create a simple two column layout by hand. Here are a few quick reference links to the files created in this video:

Feb 12 10

Intro to CSS – Basics + Selectors

by Brad

In this Intro to CSS video tutorial we learn how to add basic styles to a page with CSS. First, we link to an external style sheet, and then we learn the basic syntax of CSS, as well as four of the most common CSS Selector types; (1) type selectors, (2) ID selectors, (3) class selectors, and (4) descendant selectors.

To view this lesson in full written form, see:

Feb 12 10

How To Add an Image To a Web Page

by Brad

In this video we learn how to insert an image into a web page by hand, using HTML code. We also learn how and why to use the “alt” attribute, and how to organize images into sub-folders.

Quick Code Reference

<img src="image-name.jpg" alt="Short description of image" />

Notice there is no </img> end tag. This is because the <img> element is a Self Closing Element.  Unlike a paragraph, we won’t have a plethora of content inside our <img> element, but rather a single image.   The /> at the end of the code tells the web browser to end the image element.

For a full written tutorial, see How to Insert an Image in HTML.

Feb 12 10

Learn Basic HTML Structure – How To Link Pages

by Brad

In this video we learn the basic structure of an HTML file, and also, how to create hyperlinks. Viewers learn how to divide their HTML file into the <head> and <body> sections, and also get their first taste of HTML attributes by creating a hyperlink (href attribute).

To view a written tutorial, see:

Feb 12 10

Create Your First Web Page – For Absolute Beginners

by Brad

In this video we learn how to create and save our first web page. The basic structure of HTML is covered and is intended to familiarize viewers with HTML before moving on to more advanced concepts. We create a heading (h1), paragraph (p) and an unordered list (ul).

To view a full written tutorial, see:

Jan 25 10

CSS Lesson 6: Shorthand Properties (Padding and Margin)

by Brad

The padding and margin CSS properties are essential in building web layouts.  Since rectangles (block level elements) have four corners, you will frequently need to assign four different padding properties to one element.  If you are a beginner, this is the code you would likely use:

#header {
    padding-top: 10px;
    padding-right: 15px;
    padding-bottom: 6px;
    padding-left: 15px;
}

However, there is a much more efficient (not to mention easier!) way of applying four padding or margin values. Here is your first glimpse of CSS Shorthand in action; the following code achieves the same exact results as the padding example I just provided:

CSS Shorthand graph

You simply list four values, one directly after the other, and the web browser interprets this as the four (clockwise- top, right, bottom, left) directional values.

Similarly, you can also list two values in a row and the browser will interpret the first to be both top and bottom, and the second value to be both left and right.

CSS Shorthand graph 2

Using this new knowledge, let’s imagine we need to add 10 pixels of right margin and 15 pixels of bottom margin to an element. Here’s the code we would use:

#header {
    margin: 0 10px 15px 0;
}

We used the four-value shorthand syntax, and simply included zeroes for the directions (top and left) we didn’t want to apply margin to.

That’s it for today’s lesson. Hopefully your CSS code will be a little cleaner with these simple shorthand methods.

Jan 25 10

CSS Lesson 5: Understanding The Box Model Part 2: Margin

by Brad

As you begin designing layouts with CSS you will inevitably need to create spacing between elements; thus, today’s lesson is regarding the “margin” property.  Let’s begin with a quick image to illustrate the margin property in action:

CSS Margin Graph

Margin is space added to the outside of an element (past the element’s edge, or border).  In some instances, Padding and Margin can be used to achieve a similar affect, but it’s important to understand the difference.  Padding adds space to the inside of an element, while margin adds space to the outside of an element.

Let’s code a simple example of margin in action.  Begin with the following HTML code, and place it in a blank XHTML starter file.

<div id="box-a">
<p>Box A</p>
</div>

<div id="box-b">
<p>Box B</p>
</div>

Next, let’s give these two boxes a width, background-color, a border and padding.  Add the following code to your CSS file:

#box-a {
    width: 300px;
    padding: 15px;
    background-color: orange;
    border: 1px solid black;
}

#box-b {
    width: 300px;
    padding: 15px;
    background-color: gray;
    border: 1px solid black;
}

When viewed in a web browser, our example should look like this:

CSS Margin screenshot

Now imagine we want to create 10 pixels of spacing between the two boxes.  We would achieve this by adding bottom-margin to box-a:

#box-a {
    margin-bottom: 10px;
    width: 300px;
    padding: 15px;
    background-color: orange;
    border: 1px solid black;
}

When refreshed in our web browser, our page should now look like this:

CSS Margin Screenshot 2

You may wonder, “Could we have also added margin-top to box-b?”  Let’s do that now; let’s double the space between the boxes by adding another 10 pixels of margin to box-b:

#box-b {
    margin-top: 10px;
    width: 300px;
    padding: 15px;
    background-color: orange;
    border: 1px solid black;
}

When you refresh the page in your web browser, you’ll notice that the spacing didn’t double; it stayed exactly the same. This is because two margins are touching, so one collapsed. Essentially, when two margins touch the larger margin is used, and the smaller disappears (or collapses).

To fully illustrate this point, let’s change the margin-top of box-b from 10 pixels to 11. When we refresh the page in our web browser we’ll notice that the spacing hasn’t ballooned to 21 pixels, but instead has increased by only one pixel.

CSS Margin Screenshot 3

The browser uses the 11 pixel margin of box-b and collapses the smaller 10 pixel margin of box-a.

That’s all for today’s lesson.  To recap, you now know:

  • The difference between margin and padding
  • How to use margins to create spacing around elements
  • How the smaller of two touching margins collapses

Continue to Next Lesson