tags:

views:

32

answers:

4

Hi there!

I'm sending e-mails about weekly food orders. This is practically means 1, 2 or 3 tables. I'm trying to eliminate any unnecessary HTML from source to save bandwidth. Now there's one thing remained:   It costs 6 bytes when the client hasn't ordered anything at a day.

When i change the   to a simple space it breaks my table.

Is there any effective solution to throw out the non-breaking space without to collapse my table cells?

Thanks, fabrik

Update:

Thanks for the answers all of them does what i want after all i should accept Joeri's answer because some e-mail clients (Mozilla Thunderbird, Windows for example) totally messed up with the solutions below.

+2  A: 

You may try this, but it won't work in all browsers/e-mail clients:

<table style="empty-cells: show">
Sjoerd
A: 

Alt+0160 produces a blank, non-breaking space character:  

Chris
+1  A: 

You can add the character, that is represented by &nbsp;, literally. It's the Unicode codepoint U+00A0. Input methods:

  • vi: <C-k>NB
  • Windows: ALT+0160
  • Wikipedia
  • Perl:

    perl -i -n -p 's/&nbsp;/\x{A0}/g' email.html
    

Although, as Joeri Hendrickx points out in his answer, entering characters beyond ASCII literally might lead to problems in all positions of the email toolchain, starting from the client of the sender (if you happen to use the HTML as a template for a, say, Outlook user) and ending at the receiver's inbox server and client, that process it.

I'd like to join Joeri in his advice to leave the &nbsp; unchanged and live with the extra bytes. If you've got lots of them, try to refactor the HTML instead.

Boldewyn
+2  A: 

The problem with doing this is that email clients vary greatly. When sending html emails you should always use things that most clients will understand. nbsp (non-breaking space) is such a thing. The css attribute will probably be unrecognised by quite some clients, and unicode will probably not be supported.

So I think in this case you're stuck with the nbsp.

About entering it direct: The entities (such as this one) exist because a lot of old systems only support 7 bit ascii. The nonbreaking space (codepoint 160) is beyond that. There's also a chance there you'll run into a system that doesn't support it, but I guess that has to do with the codepage they use.

Joeri Hendrickx
+1: Old email clients are more common than one might think.
Boldewyn