在电子邮件中设置tr或td的样式? [英] styling tr or td in emails?
问题描述
我想更改整个行单元格的背景颜色和字体大小. (使用内嵌样式,因为我不能使用样式表或<style>
标签)
我应该添加哪个样式的元素?我应该将它们分别添加到每个<td>
行中,还是一次添加到<tr>
标签中?哪种方法更好?
<tr>
<td style="background-color:red;font-size:12px">blah blah</td>
<td style="background-color:red;font-size:12px">blah blah</td>
</tr>
或
<tr style="background-color:red;font-size:12px">
<td>blah blah</td>
<td>blah blah</td>
</tr>
在td
上设置属性会更安全,因为如果在tr
上设置属性,则 any 样式表td
上的属性设置(可能在您的控制范围之外)将覆盖您的设置.
但是,如果您希望控制这种情况并且不知道其他样式表设置会造成干扰,则可以在tr
上设置属性,该属性在使用style
属性时较短.这样,单元格将继承字体属性,并且将具有透明背景(默认设置),因此tr
背景会照亮.
但是,并非所有属性都被继承.例如,没有边框属性,因此要在单元格上绘制边框,需要在td
元素上设置边框(除非您对table
元素上的HTML属性必须提供的非常有限的可能性感到满意). /p>
I want to change whole row cells background-color and font-size. (with inline-styles, because I can't use stylesheets or <style>
tag)
Which element should I add these styles? I should add them on each <td>
in one row or once for <tr>
tag? which way is better?
<tr>
<td style="background-color:red;font-size:12px">blah blah</td>
<td style="background-color:red;font-size:12px">blah blah</td>
</tr>
or
<tr style="background-color:red;font-size:12px">
<td>blah blah</td>
<td>blah blah</td>
</tr>
Setting the properties on td
is safer in the sense that if you set them on tr
, then any style sheet setting (possibly outside your control) for the properties on td
will override your settings.
But if you expect to control the situation and to know that no other style sheet settings can interfere, you can set the properties on tr
, which is shorter when using style
attributes. That way, the cells will inherit font properties and they will have transparent background (the default), so the tr
background shines through.
However, not all properties are inherited. For example, border properties aren’t, so to draw borders on cells, you need to set them on td
elements (unless you are happy with the very limited possibilities that HTML attributes on table
element have to offer).
这篇关于在电子邮件中设置tr或td的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!