2

Which inline style format better for an HTML email template:

<table height="800"></table>
<table bgcolor="#000000"></table>

or

<table style="height:800px;"></table>
<table style="background:#000000;"></table>
Malka S
  • 133
  • 1
  • 9

4 Answers4

5

height="800px" is invalid. You would want height="800" (no px in height attribute). The CSS version should work in many clients, but @John reports that there is not 100% compatibility with it.

By far the best thing to do with e-mails is to not set a height at all though, since it doesn't really work. Let your content flow.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Thanks Brad, I was just using height as an example! – Malka S Mar 20 '14 at 17:06
  • @WesleyMurch This isn't about being in the stone age, it's about compatibility. IE 3.0 doesn't know how to handle a non-numeric height attribute. You need to just use a numeric value for that attribute if you go that route. – Brad Mar 20 '14 at 17:12
  • @Brad `height="800"` works 100% in all clients when applied to table/td elements, it is only `height:800px;` that doesn't work consistently. You should update the answer as it is not technically correct. – John Mar 20 '14 at 17:44
  • @John Interesting... It's been awhile since I've done an e-mail template. Do you know what clients had trouble with CSS height? I don't recall seeing any issues in Litmus, but I suppose it may have changed since then. – Brad Mar 20 '14 at 17:54
  • @Brad Not sure, I haven't checked recently as I remember it to be spotty and `height=""` is an easy alternative. My guess would be one of the Outlooks. I could be wrong on that - I'll have to check. I guess what I'm trying to say is that `height=""` is a 100% supported solution vs your comment about height in general not working. – John Mar 20 '14 at 18:02
  • @John Thanks. The answer has been edited with the information you have provided. – Brad Mar 20 '14 at 18:09
1

You can use both nowadays. However, if you want to be bullet proof use height="800" which works better for some older clients

Petar Vasilev
  • 4,281
  • 5
  • 40
  • 74
0

the first one

<table height="800"></table>
Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49
0

height="800" works in all clients and is the way you should do it. height:800px; does not.

Same for background, the 100% supported method is bgcolor="#000000", but only in <table> or <td> elements.

You should always use the top examples if you expect to get consistency across email clients.

This rule also applies to align="left" (correct) vs text-align:left; or float:left;, and valign="top" also works where vertical-align:top; is useless.

John
  • 11,985
  • 3
  • 45
  • 60