改变节省长度而不折叠表格单元格

发布于 2024-09-15 22:09:01 字数 369 浏览 8 评论 0原文

我正在发送有关每周食品订单的电子邮件。这实际上意味着 1、2 或 3 个表。我正在尝试从源代码中消除任何不必要的 HTML 以节省带宽。现在还剩下一件事:  当客户一天没有订购任何东西时,它会花费 6 个字节。

当我将   更改为简单的空格时,它会破坏我的桌子。

有没有有效的解决方案可以扔掉不间断的空格而不折叠我的表格单元格?

更新:

感谢您的回答,他们都做了我想要的事情,毕竟我应该接受Joeri的回答,因为一些电子邮件客户端(例如Mozilla Thunderbird,Windows)完全混乱与下面的解决方案。

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?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

围归者 2024-09-22 22:09:02

您可以添加按字面意思表示的字符  。它是 Unicode 代码点 U+00A0。输入法:

  • vi: NB
  • Windows: ALT+0160
  • 维基百科
  • Perl:

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

虽然,正如 Joeri Hendrickx 在他的回答中指出的那样,输入超出 ASCII 字面量的字符可能会导致电子邮件工具链的所有位置出现问题,从发件人的客户端开始(如果您碰巧使用 HTML 作为 Outlook 用户的模板)并结束于接收者的收件箱服务器和客户端,对其进行处理。

我想加入 Joeri 的建议,保持   不变并接受额外的字节。如果您有很多此类内容,请尝试重构 HTML。

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

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

    perl -i -n -p 's/ /\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   unchanged and live with the extra bytes. If you've got lots of them, try to refactor the HTML instead.

So尛奶瓶 2024-09-22 22:09:02

Alt+0160 产生一个空白的不间断空格字符: 

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

浮生面具三千个 2024-09-22 22:09:02

尝试将 TABLE DATA 与   保持在同一行。相信我,它有效!

`

 <tr>

       <td width="50"> </td>

 </tr>

`

Try keeping the TABLE DATA with the   on the same line. trust me it works!

`

 <tr>

       <td width="50"> </td>

 </tr>

`

春夜浅 2024-09-22 22:09:01

这样做的问题是电子邮件客户端差异很大。发送 html 电子邮件时,您应该始终使用大多数客户都能理解的内容。 nbsp(不间断空格)就是这样的东西。相当多的客户端可能无法识别 css 属性,并且可能不支持 unicode。

所以我认为在这种情况下你只能选择nbsp。

关于直接输入:实体(比如这个)的存在是因为很多旧系统只支持7位ascii。不间断空格(代码点 160)超出了这个范围。您也有可能会遇到不支持它的系统,但我想这与他们使用的代码页有关。

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.

安稳善良 2024-09-22 22:09:01

您可以尝试此操作,但它不适用于所有浏览器/电子邮件客户端:

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

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

<table style="empty-cells: show">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文