HTML Hints

Here are some HTML table properties and styles that will help you create an email message.  If you are trying to solve some specific issues with your messages, please take a look at our HTML Email Design Guidelines.

How to add a left-border and right-border to a table and color it.

Within the table or the table cell tags, you can use the border property (border-style, border width, and border color)  to specify the style and color of an element's border.

The <table> tag defines an HTML table.

The <td> tag defines a standard cell in an HTML table.

To shorten the code, you can specify all the border properties in one property, this is called a shorthand property. For the border properties, the "border" values are:

  • border-width: used to set the width of the border, set in pixels
  • border-style: specifies what kind of border to display.
  • border-color: used to set the color of the border
Example table border
<table>
	<tbody>
		<tr>
 			<td style="border: 1px solid #000000;">
            	Height
			</td>
            <td style="border: 1px dashed #000000;">
            	Weight
			</td>
		</tr>
		<tr>
 			<td style="border: 2px dotted #FFFFFF;">
            	Males
			</td>
            <td style="border: 2px double #FFFFFF;">
            	1.9
			</td>
		</tr>
		<tr>
 			<td style="border: 1px solid #000000;">
            	Females
			</td>
            <td style="border: 1px solid #000000;">
            	1.7
			</td>
		</tr>
	</tbody>
</table>

 

It does not matter if one of the values above are missing (although, border-style is required), as long as the rest are in the specified order.

Also, you can even use "border - individual sides" properties so that it is possible to specify different borders for different sides (definition shown below).

Here are the Optional Table Attributes

DTD indicates in which HTML 4.01/XHTML 1.0  DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute
Value
Description
DTD
alignleft     center     rightDeprecated. Use styles instead. Specifies the alignment of a table according to surrounding textTF
bgcolorrgb(x,x,x)     #xxxxxx     colornameDeprecated. Use styles instead. Specifies the background color for a tableTF
borderpixelsSpecifies the width of the borders around a tableSTF
cellpaddingpixelsSpecifies the space between the cell wall and the cell contentSTF
cellspacingpixelsSpecifies the space between cellsSTF
framevoid       above       below       hsides       lhs       rhs       vsides       box       borderSpecifies which parts of the outside borders that should be visibleSTF
rulesnone       groups       rows       cols       allSpecifies which parts of the inside borders that should be visibleSTF
summarytextSpecifies a summary of the content of a tableSTF
widthpixels       %Specifies the width of a table

STF

 

Here are the Optional TD Attributes 

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute
Value
Description
DTD
abbrtextSpecifies an abbreviated version of the content in a cellSTF
alignleft
right
center
justify
char
Aligns the content in a cellSTF
axiscategory_nameCategorizes cellsSTF
bgcolorrgb(x,x,x)
#xxxxxx
colorname
Deprecated. Use styles instead.
Specifies the background color of a cell
TF
charcharacterAligns the content in a cell to a characterSTF
charoffnumberSets the number of characters the content will be aligned from the character specified by the char attributeSTF
colspannumberSpecifies the number of columns a cell should spanSTF
headersheader_idSpecifies one or more header cells a cell is related toSTF
heightpixels
%
Deprecated. Use styles instead.
Sets the height of a cell
TF
nowrapnowrapDeprecated. Use styles instead.
Specifies that the content inside a cell should not wrap
TF
rowspannumberSets the number of rows a cell should spanSTF
scopecol
colgroup
row
rowgroup
Defines a way to associate header cells and data cells in a tableSTF
valigntop
middle
bottom
baseline
Vertical aligns the content in a cellSTF
widthpixels
%
Deprecated. Use styles instead.
Specifies the width of a cell
TF

 

Border Style values

none: Defines no border

dotted: Defines a dotted border

dashed: Defines a dashed border

solid: Defines a solid border

double: Defines two borders. The width of the two borders are the same as the border-width value

groove: Defines a 3D grooved border. The effect depends on the border-color value

ridge: Defines a 3D ridged border. The effect depends on the border-color value

inset: Defines a 3D inset border. The effect depends on the border-color value

outset: Defines a 3D outset border. The effect depends on the border-color value

Border Width

The width is set in pixels, or by using one of the three pre-defined values:  thin, medium, or thick.

Note: The "border-width" property does not work if it is used alone. Use the "border-style" property to set the borders first.

Border Color

The color can be set by:

  • name - specify a color name, like "red"
  • RGB - specify a RGB value, like "rgb(255,0,0)"
  • Hex - specify a hex value, like "#ff0000"

You can also set the border color to "transparent".

Note: The "border-color" property does not work if it is used alone. Use the "border-style" property to set the borders first.

Border - Individual sides

The border-style property can have from one to four values.

  • border-style:dotted solid double dashed;
    • top border is dotted
    • right border is solid
    • bottom border is double
    • left border is dashed
  • border-style:dotted solid double;
    • top border is dotted
    • right and left borders are solid
    • bottom border is double
  • border-style:dotted solid;
    • top and bottom borders are dotted
    • right and left borders are solid
  • border-style:dotted;
    • all four borders are dotted

The border-style property is used in the example above. However, it also works with border-width  and border-color.

Here are all the Border Properties:
Property
Description
borderSets all the border properties in one declaration
border-bottomSets all the bottom border properties in one declaration
border-bottom-colorSets the color of the bottom border
border-bottom-styleSets the style of the bottom border
border-bottom-widthSets the width of the bottom border
border-colorSets the color of the four borders
border-leftSets all the left border properties in one declaration
border-left-colorSets the color of the left border
border-left-styleSets the style of the left border
border-left-widthSets the width of the left border
border-rightSets all the right border properties in one declaration
border-right-colorSets the color of the right border
border-right-styleSets the style of the right border
border-right-widthSets the width of the right border
border-styleSets the style of the four borders
border-topSets all the top border properties in one declaration
border-top-colorSets the color of the top border
border-top-styleSets the style of the top border
border-top-widthSets the width of the top border
border-widthSets the width of the four borders

In this example, here's a simple table that illustrates some of the features of the HTML table model. The following table definition:

<table border="1">
            <caption>
                <em>A test table with merged cells</em></caption>
            <tbody>
                <tr>
                    <th rowspan="2"></th>
                    <th colspan="2">
                        Average</th>
                    <th rowspan="2">
                        Red<br>
                        eyes</th>
                </tr>
                <tr>
                    <th>
                        height</th>
                    <th>
                        weight</th>
                </tr>
                <tr>
                    <th>
                        Males</th>
                    <td>
                        1.9</td>
                    <td>
                        0.003</td>
                    <td>
                        40%</td>
                </tr>
                <tr>
                    <th>
                        Females</th>
                    <td>
                        1.7</td>
                    <td>
                        0.002</td>
                    <td>
                        43%</td>
                </tr>
            </tbody>
        </table>

 

In the eMail Networks editor, you can do an Inbox email preview in your account:

Now, let's add a 5px solid green border around the table, a 3px red dotted border around the 0.003 table cell, and a 6px blue dashed border around the 43% table cell.

 

<table align="center" bgcolor="white" border="5" bordercolor="green" 
style="border-style: outset;" summary="This table gives some statistics 
of average height and weight, and percentage; with red eyes (for both 
males and females)." width="600">
            <caption>
                <em>A test table with merged cells</em></caption>
            <tbody border-style:dotted="" solid="">
                <tr>
                    <th rowspan="2">
                        &nbsp;</th>
                    <th colspan="2">
                        Average</th>
                    <th rowspan="2">
                        Red<br>
                        eyes</th>
                </tr>
                <tr>
                    <th>
                        height</th>
                    <th>
                        weight</th>
                </tr>
                <tr>
                    <th>
                        Males</th>
                    <td 2px="" dashed="" red="">
                        1.9</td>
                    <td style="background: white; margin: 0px auto; border: 3px dotted red; width: 100px;">
                        0.003</td>
                    <td>
                        40%</td>
                </tr>
                <tr>
                    <th>
                        Females</th>
                    <td>
                        1.7</td>
                    <td>
                        0.002</td>
                    <td style="background: white; margin: 0px auto; border: 6px dashed blue; width: 50px;">
                        43%</td>
                </tr>
            </tbody>
        </table>