Html 对于电子邮件通讯,我应该使用双 br 标签来减少一些内联代码吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15137780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
For an email newsletter should I use double br tags to reduce some inline code?
提问by Ryan
Since I'm styling inline using <span>
or <p>
tags should I maybe just go real old school and use <br><br>
to break paragraphs instead of closing and reopening the <p>
tag each time?
由于我使用<span>
或<p>
标签进行内联样式设置,我是否应该去真正的老派并使用<br><br>
打破段落而不是<p>
每次关闭和重新打开标签?
For example here's a snippet of code that I currently have and its just so redundant. I know that's the nature of having to code inline but seems like I might be able to reduce some noise by doing <br><br>
例如,这是我目前拥有的一段代码,它只是多余的。我知道这是必须内联编码的本质,但似乎我可以通过这样做来减少一些噪音<br><br>
<p style="font-size: small; font-family:Tahoma, Geneva, sans-serif">Selection of the 200 New & Recently updated companies over the last month. Click on the company name for up-to-date business information.</p>
<p style="font-size: small; font-family:Tahoma, Geneva, sans-serif">Company Name, FL provider of Category was updated on 2/12/2013</p>
<p style="font-size: small; font-family:Tahoma, Geneva, sans-serif">Company Name, TX provider of Category was updated on 2/13/2013</p>
<p style="font-size: small; font-family:Tahoma, Geneva, sans-serif">Company Name, AK provider of Category was updated on 2/15/2013</p>
Is there a downside to switching some of this out when applicable for <br><br>
? Email client support or anything like that?
在适用的情况下,将其中的一些切换出来是否有不利之处<br><br>
?电子邮件客户端支持或类似的东西?
采纳答案by niaccurshi
Feel free to use the line break tags, you quite rightly have already identified the potential for reducing your markup this way, and there are no disadvantages to doing this. Every email client and web client supports them, and they're more reliable than using margins on paragraph tags, since margins aren't supported comprehensively across all systems.
随意使用换行标记,您完全正确地已经确定了以这种方式减少标记的潜力,并且这样做没有任何缺点。每个电子邮件客户端和 Web 客户端都支持它们,并且它们比在段落标签上使用边距更可靠,因为并非所有系统都全面支持边距。
Reference: http://www.campaignmonitor.com/css/
回答by John
I use double <br>
tags between all text. It is the most consistent option for email.
我<br>
在所有文本之间使用双标签。这是电子邮件最一致的选择。
You'll need to pair it with a
though at the top and bottom of your text as it can in some clients (Outlook I think) will compress empty lines. Here is an example:
您需要将它与
文本顶部和底部的尽管配对,因为它可以在某些客户端(我认为是 Outlook)中压缩空行。下面是一个例子:
<td>
<br>
The no break space is needed above and below the text where it meets the table cell.
<br><br>
double br's between paragraphs are the best way to do it.
<br><br>
You need 1 no break space per line at the bottom (and top) so that Outlook doesn't remove the text row.
<br> <br>
</td>
This is the quickest way, but limits you to multiples of your line-height. Another option is to use padding:
这是最快的方法,但将您限制为行高的倍数。另一种选择是使用填充:
<td style="padding-top:15px; padding-bottom:30px;">
The no break space is needed above and below the text where it meets the table cell.
<br><br>
double br's between paragraphs are the best way to do it.
<br><br>
You need 1 no break space per line at the bottom (and top) so that Outlook doesn't remove the text row.
</td>
Assuming the line-height was set at 15px, both these methods will produce the same results and are widely supported in all major email clients.
假设 line-height 设置为 15px,这两种方法将产生相同的结果,并且在所有主要电子邮件客户端中得到广泛支持。