Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In the prior two videos, we worked to code this one-column HTML email. Let's finish coding this email. Because email software can display HTML email code differently, the next step is to style parts of the email, so that it will display fine no matter what email software is used to display it. We use Cascading Style Sheets styles, or CSS styles, to make this happen. First we'll look at our code for our email. If you notice in the head area of our email, we don't have a reference to a CSS style sheet.
The reason is that HTML emails do not use style sheets, either inside the email or outside as a reference, the way that web pages do. The reason for that is very simple. Quite a lot of HTML email software gets rid of style sheets, or ignores an override style sheets. Instead, we need to use our CSS styles within each of our HTML tags within the body of our email, and that's what we'll begin to do. If you recall, we took our one-column email, we turned the design into a set of HTML tables, we had a large box, this plum-colored area, and we had a box that contained the email, and against that, we have the background image.
Then we had a box for News content, and we had a box for the footer links. So let's tackle first styling the background image for this larger box. The first thing we'll do is we'll create an inline style. We'll actually use HTML table code for this. We're going to do use this simple background= element for the HTML table. In addition, because of Outlook 2007, 2010, and Google Mail not handling background images well, or the same, what we'll do is we'll code specifically for those situations, and that starts up here with the body tag.
We'll add this style with these values. The second step is to add specific code for Microsoft Outlook, and that's what this code is here. A key point in this code is that there are two instances where you need to note the height and the width of the image: here for the height, and you see it replicated up here, highlighted up here, and then also for the width up here. All the rest of this code can remain the same, and these are all in the exercise files.
Now, we put this code for Outlook above where our content begins, as I've noted in the actual file. So then we add our content, we've added our copy, and then down here at the end of our content, we will finish off this Outlook-specific code by adding these three lines. Next, let's style another part of our design. Let's look at this News box. There's content in it that needs to be styled, and then in the box itself we'll see has been styled to make it work.
So let's go back up here to the start of our News content and you'll see here this is the beginning of the News box. You'll see that we've added CSS styles here. Specifically, we've set the margin-top to 170 pixels. This represents the distance from the top of the large box all the way down to the top of our content box. Then we've also set the margin-left to 17 pixels, and this represents the distance from the left edge of this large box to the content box.
So, we've styled the table box for the News. Then for the content inside of our News box, or HTML table, we have a heading1 style, and we've defined a whole series of styles. They look very complex, but in fact they are really quite simple. We've defined the color, then we defined all the font styles, all the elements, so what's the font-family, the font-size, the font-weight, the line-height of the fonts. In addition we've set all the margin and padding all to 0, except for the padding-bottom of 10%, and if you look at our design, you'll see that in fact there's a thin amount of spacing between there.
Then we have our content for the heading in a single line, and we close off our heading tag. You see that we follow the same approach for the paragraph tags in our content area. We define a whole set of styles here, starting with the color, then the font-family, the font-size, the line- height, and then the margin and padding settings. As an aside, what I do for CSS styles, I tend to alphabetize them. So color here begins with a letter C, that goes at the beginning, line-height that goes after fonts, etc.
It makes it lot easier to find what you need to change if you in fact you have to come back and change your code. So we close off our paragraph tag there. So the third element that we're going to style is the footer table. You'll see that we do the same strategy. On the table data cell, we have a whole set of styles. You'll see up here for the table itself, we set the margin-top to 125 and the margin-left to 90. If we go back to our original image, you'll see that this represents this space from here, the bottom of the news, to the top of the footer, and this is the indent for the footer table.
So this is all calculated in that planning session where I take a single page of paper and I map out all of the height and width and everything. It makes it easy when actually sit down to code to figure out what to put in for these CSS styles. Then we go to the paragraph tags within the footer, and again they should look very familiar by now. We define the color, we define the font-family, the size, the margin-left, and padding, and all of those values set to 0. The anchor tag, we set to a color because we want it to be a little bit different in its design.
We can also set up a link here, and then as we scroll down, we'll repeat these CSS styles for every one of the paragraph tags and then as appropriate for each of the links. Again, we keep our content on its own separate line so that it makes it easy to keep content separate from all of this heavy-duty inline CSS. Finally, we get down here, and you can see we've done the same thing. We've styled the paragraph tags, we've styled the anchor tags, and we have a complete one-column HTML email in code. The process we followed is used every time you need to create an HTML email, no matter how complex the design.
In future videos, we'll show how to design a two-column HTML email, as well as a multiproduct HTML email.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97566 Viewers
80 Video lessons · 141073 Viewers
59 Video lessons · 59423 Viewers
52 Video lessons · 72747 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.