Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Adding inline CSS

From: Effective HTML Email and Newsletters

Video: Adding inline CSS

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.

Adding inline CSS

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.

Show transcript

This video is part of

Image for Effective HTML Email and Newsletters
Effective HTML Email and Newsletters

55 video lessons · 22186 viewers

Tim Slavin
Author

 
Expand all | Collapse all
  1. 2m 25s
    1. Welcome
      1m 1s
    2. Using the exercise files
      1m 24s
  2. 13m 12s
    1. Understanding differences between HTML email and web pages
      1m 21s
    2. Seeing how HTML email displays in different email programs
      3m 27s
    3. Finding Acid tests and compatibility checklists
      2m 35s
    4. Understanding MIME types: HTML vs plain text
      4m 3s
    5. Exploring the future of HTML email
      1m 46s
  3. 15m 12s
    1. Defining spam
      2m 6s
    2. Examining legal issues with permission-based email
      1m 33s
    3. Planning email campaigns
      1m 36s
    4. Creating content for email campaigns
      2m 34s
    5. Understanding design constraints of HTML email
      1m 53s
    6. Designing effective HTML email
      2m 5s
    7. Building email address lists
      3m 25s
  4. 7m 28s
    1. Choosing tools for coding HTML email
      1m 27s
    2. Coding email versus coding web pages
      1m 14s
    3. Preventing problems with email coding
      2m 49s
    4. Understanding the ideal coding process
      1m 58s
  5. 17m 27s
    1. Planning
      1m 8s
    2. Coding HTML tables
      4m 38s
    3. Adding content
      4m 49s
    4. Adding inline CSS
      6m 52s
  6. 10m 44s
    1. Planning
      43s
    2. Coding HTML tables
      2m 41s
    3. Adding content
      3m 39s
    4. Adding inline CSS
      3m 41s
  7. 13m 13s
    1. Planning
      1m 13s
    2. Coding HTML tables
      3m 4s
    3. Adding content
      2m 37s
    4. Adding images
      1m 9s
    5. Adding inline CSS
      5m 10s
  8. 7m 32s
    1. Designing a plain text email
      4m 49s
    2. Designing a plain text email from an HTML email
      2m 43s
  9. 20m 45s
    1. Automating HTML email creation
      2m 5s
    2. Automating HTML email by category
      1m 6s
    3. Automating HTML email with WordPress
      5m 32s
    4. Automating HTML email with ExpressionEngine
      4m 27s
    5. Automating HTML email with FeedBurner from an RSS feed
      4m 27s
    6. Automating HTML email with FeedBlitz from an RSS feed
      3m 8s
  10. 6m 42s
    1. Deciding when and how to test email
      3m 18s
    2. Using testing services
      3m 24s
  11. 13m 56s
    1. Outsourcing your email campaign
      56s
    2. Sending email with MailChimp
      2m 40s
    3. Sending email with Campaign Monitor
      1m 51s
    4. Sending email with Constant Contact
      2m 20s
    5. Sending email with iContact
      2m 9s
    6. Sending email with VerticalResponse
      1m 52s
    7. Sending email with canned templates
      2m 8s
  12. 14m 34s
    1. Solving layout and spacing problems
      2m 50s
    2. Solving image problems
      3m 12s
    3. Solving Gmail display problems
      2m 19s
    4. Solving Lotus Notes display problems
      1m 55s
    5. Solving Outlook 2007/2010 display problems
      2m 40s
    6. Adding video to email
      1m 38s
  13. 1m 36s
    1. Next steps
      1m 36s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Effective HTML Email and Newsletters.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.