HTML table cell with width less than 1% percent - html

Wondering if it is possible to somehow specify a table cell's width in the form of a percentage less than 1%. In XHTML 1.0 strict, without the use of CSS.
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td width="70%">..</td>
<td width="0.5%"></td>
<td width="0.5%"></td>
<td width="29%">..</td>
</tr>
</table>
Is this possible? Is it valid? Does it work cross-platform? Anyone know of a way? When I attempt to use the code above, it appears to interpret 5% and not a half percent.
The template will be for consumption in email clients, not a web browser.

You could try taking the middle two at 0.5% and making a single TD at 1%. Then put a table inside at 100% and have two TD's each at 50%.
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td width="70%">..</td>
<td width="1%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="middle">
<td width="50%"></td>
<td width="50%"></td>
</tr>
</table>
</td>
<td width="29%">..</td>
</tr>
</table>

Use CSS.....
Try this!
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td style="width:70%">..</td>
<td style="width:0.5%"></td>
<td style="width:0.5%"></td>
<td style="width:29%">..</td>
</tr>
</table>

Related

How can i achieve img coming out from border. email templates?

http://imgur.com/a/fKv2H
I need banner with height 100px. and img inside it with height 120px. So the picture comeee out my banner for 20px;
Its for emails.
Also i need text column right before picture, so that text in column with background f4f4f4
<table>
<tr>
<td>
<img src="" style="margin-top:-20px;" />
</td>
<td>
banner text here
</td>
</tr>
</table>
You can do this two ways, one involved slicing the image into two and the other is using two more tables. I have added the code below for you to decide which one you want to go with.
Option 1:
This option has the image as one piece sitting in an outer table with 3 columns. The outer two columns have a table with white background to cater for the heads/hats popping out of the grey area. I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
<td width="171" valign="top"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Option 2
For this option, you will need to slice the top part of the image (with white background) and place both the images in one table with two rows. Both images are centered and I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" valign="top" bgcolor="#ffffff"><img src="http://i64.tinypic.com/lz7f6.png" style="display: block;">
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#f4f4f4"><img src="http://i68.tinypic.com/4qo1mu.png" style="display: block;"></td>
</tr>
</tbody>
</table>
The final outcome for both codes should look like this:
Let me know which option best suits you.
** UPDATE **
Your question asked if you can have option 1 with image to the left and text on the right, here is the example:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="171" valign="top" style="padding-left:20px;"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
<tr>
<td style="font-family:Arial; font-size:12px; color:#000000; padding:5px 10px;">This is some text for your email</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I added colors so you could see that it was outside the table. I gave the image a height of 120px, width of auto. Made the td's have a max-height of 100px; And I left your -20px margin on the image.
<body style="background-color:pink">
<table style="background-color:orange;">
<tr>
<td style="max-height:100px; overflow-y:initial;">
<img src="https://i.imgur.com/ZESO4DT.png" style="margin-top:-20px; height:120px; width:auto;" />
</td>
<td style="max-height:100px;overflow-y:initial;">
banner text here
</td>
</tr>
</table>
</body>

responsive html newsletter with tables like bootstrap

I'd like to send a responsive newsletter. I know how to do it with my style.css
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" bgcolor="#fff">
<tbody>
<tr>
<td style="padding-bottom:5px" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="295" style="background:#ffffff">
<tbody>
<tr>
<td style="padding:15px;background-color:#fff">
image
</td>
</tr>
</tbody>
</table>
</td>
<td style="padding-bottom:5px" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="295" style="background:#ffffff">
<tbody>
<tr>
<td style="padding:15px;background-color:#fff">
text
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="padding-bottom:5px" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="295" style="background:#ffffff">
<tbody>
<tr>
<td style="padding:15px;background-color:#fff">
text
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
but I have one problem.
In desktop looks great,
image text
text image
but in mobile
looks
image
text
text
image
and I want it like
image
text
image
text
I found Column order manipulation using col-lg-push and col-lg-pull in Twitter Bootstrap 3 and I was wondering if there is something like that in tables.
I tried to change align="center" with aling="left" and align="right" but nothing.
Can anyone help me?
Rather than getting the side-by-side effect by using two table cells (td's), you need to make each side a whole table, and use the align property on the table. This lets you have the left or right sides in either order when the email goes to one column.
Julie Ng's Antwort template has a good description + example of this technique:
https://github.com/InterNations/antwort/wiki/Columns-to-Rows-%28Version-1.0%29

HTML / IOS < 6 Table Alignment

Having a little trouble with a HTML email on older versions of IOS in that tables will not align next to eachother. I am creating a responsive email layout for a client and have a need to use align="left" to float tables. ( sample code below )
I have tested on every client i can think of and it is only old IOS versions with this issue.
Sample code: ( this isnt the actual code i am using but same princible )
<table cellspacing="0" cellpadding="0" width="600" border="0" class="full-width">
<tr>
<td width="600" class="full-width">
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 1</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 2</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 3</td>
</tr>
</table>
</td>
</tr>
</table>
Here is an image of whats happening with IOS 5 (Incorrect) and IOS 6 (correct):
Image of IOS 5 and 6 respectively with table included
Any assistance would be greatly appreciated. If you need further info let me know.
You have align="200" on your table cells - not sure if it is just a typo in the sample code, but that could possibly be messing things up. Otherwise, it looks good to me, maybe try adding float:left; to the aligned tables as a fallback to see if it helps.
Also set the width of your table cells to 100% or 200 to make sure they are behaving as expected and check that your full-width class or other css isn't doing anything funky.
Right, after hours of playing around with the code the answer is... :
Make sure the container TD also as align="left" so the code would become:
<table cellspacing="0" cellpadding="0" width="600" border="0" class="full-width">
<tr>
<td width="600" class="full-width" align="left">
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 1</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 2</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="200" align="left">
<tr>
<td width="200">Some Text Here 3</td>
</tr>
</table>
</td>
</tr>

outlook 2007 ignoring cell padding

I have a table defined as
<table width="600" cellspacing="0" cellpadding="0">
<table border="0" cellspacing="0" cellpadding="25" width="600">
<tr>
<td width="160" bgcolor="#efefef">Text</td>
<td width="340" bgcolor="#ffffff">Text</td>
</tr>
</table>
<tr>
<td colspan="2"><img src="image.jpg"></td>
</tr>
</table>
Here for the image I have a gray shaded area of width 210px and the rest is white.
Now this should get aliged with the first cell since it has width 160px + 50px (cellpadding) = 210px (in total)
However, outlook 2007 does not pick up this cellpadding. How can I get this to align in outlook 2007?
first of all I think your code should change
<table width="600" cellspacing="0" cellpadding="0">
<tr><td>
<table border="0" cellspacing="0" cellpadding="25" width="600">
<tr>
<td width="160" bgcolor="#efefef">Text</td>
<td width="340" bgcolor="#ffffff">Text</td>
</tr>
</table>
</td></tr>
<tr>
<td colspan="2"><img src="image.jpg"></td>
</tr>
</table>

Table alignment issue html

<table width="100%" border="0">
<table width="600" align="center" bgcolor="#ffffff">
<tr>
<td width="600" colspan="120">Banner Image</td>
</tr>
<tr>
<td width="400" colspan="80"></td>
<td width="10" colspan="2" bgcolor="yellow"></td>
<td width="190" colspan="38"></td>
</tr>
</table>
</table>
The alignment is messed up for the 2nd row. How can it be resolved?
Looks like there are a lot of issues here.
First off, this isn't valid html. The second table tag can't go where you have it. You need to do something like:
<table width="100%" border="0">
<tr><td>
<table width="600" align="center" bgcolor="#ffffff">
<tr>
<td width="600" colspan="3">Banner Image</td>
</tr>
<tr>
<td width="400"></td>
<td width="10" bgcolor="yellow"></td>
<td width="190"></td>
</tr>
</table>
</td></tr>
</table>
Which will probably solve your immediate problem. However, why on earth do you have 120 columns? That seems wrong by any standard.
Note I removed the colspan because it's use here seemed very inappropriate.
Also, you might ask yourself why you have the outer table tag anyway. It's not exactly doing anything for you that can't be done in a better manner.
Colspan is used to indicate how many COLumns a single column SPANs, not to indicate a pixel width, as it would appear that you are trying to do here.
Instead, use colspan to indicate how many columns a single column should span, and indicate the width of columns either using css styles or the "width" atttribute.
See this example:
http://jsfiddle.net/xixionia/yt3gf/
The second table should be better if you placed it inside a td on the first table. Then on the second table there's a lot of colspan.
<div>
<table>
<tbody>
<tr>
<td width="600" colspan="3">Banner Image</td>
</tr>
<tr>
<td width="400"></td>
<td width="10" bgcolor="yellow"></td>
<td width="190"></td>
</tr>
</tbody>
</table>
</div>
I do prefer to use div in place of table. But you still have a choice. As you can refer to the other post.
You would try:
<table width="100%" >
<table align="center" bgcolor="#ffffff" cellspacing="0" cellpadding="0" border="1">
<tr>
<td colspan="120">Banner Image</td>
</tr>
<tr>
<td style="width:400px;" colspan="80">a</td>
<td style="width:10px;" colspan="2" bgcolor="yellow">b</td>
<td style="width:190px;" colspan="38">c</td> </tr>
</table>
</table>
I add "border=1" and text in the cells in order to see the changes.
You got a table inside a table directly and thats not "valid".
Considering:
I want the banner to stretch across the table. The second row should be in proportion of width 400, 10 for the separator and 190
You should have:
<table style="width:100%; background-color: #fff;">
<tr>
<td colspan="3">Banner Image</td>
</tr>
<tr>
<td style="width: 66.6%"></td>
<td style="width: 1.6%; background-color: yellow;"></td>
<td style="width: 31.6%"></td>
</tr>
</table>
You are clearly trying to use tables to make layout wireframes. You should research more about CSS and html5.
This answer will probably fix your code but not the logic you are trying to apply.