How to make XHTML "table" with fluid table rows - html

Basically i want to be able to make a a grid of boxes, where i can align text at the top middle and bottom of each box, and have the boxes on the same row resize when text in another box on its row pushes it down.
If you look at this HTML 4 code, it achieves what i want to be able to do, but id like to be able to achieve this with the XHTML 1.0 doctype.
<style type="text/css">
<!--
#apDiv1 {
width:200px;
height:100%;
border:1px solid #000;
}
#apDiv1 table{
width:200px;
height:100%;
border:1px solid #000;
}
-->
</style>
<div id="apDiv1"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>blah</td></tr>
<tr><td height="100%">blah</td></tr>
<tr><td>blah</td></tr>
</table>
</td>
<td>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>blah</td></tr>
<tr>
<td height="100%"><p>blahfhfh</p>
<p>dfhdf</p>
<p>h</p>
<p>dfh</p>
<p>df</p>
<p>h</p>
<p> </p></td></tr>
<tr><td>blah</td></tr>
</table>
</td>
<td>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>blah</td></tr>
<tr><td height="100%">blah</td></tr>
<tr><td>blah</td></tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%"><p>blahfhfh</p>
<p>dfhdf </p>
<p> </p></td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%">blah</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%">blah</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%">blah</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%">blah</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>blah</td>
</tr>
<tr>
<td height="100%">blah</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table></td>
</tr>
</table>
</div>

There's a cross-browser way to achieve grid using CSS with display:inline-block, however it may not be as flexible as you'd like (and code is pretty ugly if you want to support Firefox 2).
The issue you might have with “XHTML” is that CSS without emulation of IE5 bugs (which you get when you don't use DOCTYPE or use one of old/incomplete ones) restricts when you can use height:100%.
Height in percent doesn't work if parent element has auto height, and by default almost every HTML element has auto height. You have to set explicit height on all parent elements of the table:
html,body,#apDiv1 {
height:100%;
}

first, make your document have the DOCTYPE of HTML 4.01 strict and make it validated first, using http://validator.w3.org
then, you can change the DOCTYPE to
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and then re-validate it. If there is any problem or things that behave differently, you can ask about the specific question here.

Related

Mustache - Postmark email conditional formatting

I am trying to conditionally render a block of HTML, dependent on the presence of a key in the JSON -> custom_invite_text.
My understanding is that the Mustachio conditions control the presence of the HTML blocks below. This is working fine, but we lose access to the dynamic data provided by the JSON. Presume it is a scoping issue, but some guidance would be good?
The following HTML is used to generate an email:
<p>{{body}}</p>
{{#custom_invite_text}}
<table class="custom_invite">
<tr class="custom_invite_rows">
<td class="custom_invite_row1"><div class="roundel"><p class="roundel-text">{{custom_invite_org}}</p></div></td>
<td class="custom_invite_row2"><p class="custom_invite_heading">From {{org_name}}</p></td>
</tr>
</table>
{{/custom_invite_text}}
{{#custom_invite_text}}
<table class="body-action custom_invite_div" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="custom_invite_text" align="left">
{{{custom_invite_text}}}
</td>
</tr>
<tr class="custom_invite_btn">
<td align="center">
<!-- Border based button https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{{behaviour_url_description}}
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
{{/custom_invite_text}}
{{^custom_invite_text}}
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr class="custom_invite_btn">
<td align="center">
<!-- Border based button https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{{behaviour_url_description}}
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
{{/custom_invite_text}}
Thanks.

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>

css background image not displaying in html table

i have added this style to a table
background-image:url(square_image.png); background-size:auto; background-repeat:no-repeat;
However the image is not being displayed in the background.
The demo Jsfiddle link here
This is because you're having two inline "style" attributes.
Your updated code should be like:
<table border="0" cellspacing="0" cellpadding="5" style="width:100%; min-width:500px; max-width:700px; font-family:Arial; font-size:14px;">
<tr>
<td><table width="240" height="300px" border="0" cellpadding="2" cellspacing="0" style="font-size:12px; font-family:Arial;background-image:url('https://s32.postimg.org/wi1c9sm3p/Integra_Icons_Square_on_orange.jpg'); background-size:auto; background-repeat:no-repeat;">
<tr>
<td align="right">Text</td>
<td align="right">Text</td>
</tr>
<tr>
<td align="right">Text</td>
<td align="right">Text</td>
</tr>
<tr>
<td align="right">Text</td>
<td align="right">Text</td>
</tr>
<tr>
<td align="right">Text</td>
<td align="right">Text</td>
</tr>
<tr>
<td align="right">Text</td>
<td align="right">Text</td>
</tr>
</table></td>
</tr>
</table>
Updated jsfiddle: https://jsfiddle.net/j03mp8bc/8/
It is not allowed to use multiple attributes in HTML.
Validate your HTML before asking on StackOverflow.
https://validator.w3.org/
https://jsfiddle.net/ou366bh7/
style=""

<tr> height displaying incorrectly

I've been beating my head against a really stupid problem for the last while. Why can't I get the cell separating the two boxes to properly display at 9px?? I've done the math a couple of times and it works out, and yet in the cell w/ the arrow pointing towards it, it's adding extra height:
I actually appears to be doubling the 9 px height set for it (18px approx). Why?? This makes no sense.
<!-- BIG WRAPPER TABLE FOR CENTRAL CONTENT -->
<table width="700px" border="0" cellspacing="0" cellpadding="0" class="homepage">
<tr align="center">
<td>
<table width="681" height="451" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td rowspan="3" bgcolor="#FF66CC">Image will go here</td>
<td rowspan="3" width="9"> </td>
<td height="221" width="221" bgcolor="#3f7583">Text will go here</td>
</tr>
<tr height="9">
<td height="9" width="221" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="221" width="221" bgcolor="#CC0000">Image will go here</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END BIG WRAPPER TABLE -->
this is because of your td
<td height="9" width="221" bgcolor="#FFFFFF"> </td>
It is taking the height of your when rendered with normal font size, just remove it and it should work.
Here is the working fiddle
Instead of creating TD's for your spacing, why not just use the CellSpacing to accomplish what you need to do:
<table width="700px" border="0" cellspacing="0" cellpadding="0" class="homepage" style="font-size: 7pt;">
<tr align="center">
<td>
<table width="681" height="451" border="0" cellspacing="9" cellpadding="0" align="center">
<tr>
<td rowspan="2" bgcolor="#FF66CC">Image will go here</td>
<td height="221" width="221" bgcolor="#3f7583">Text will go here</td>
</tr>
<tr>
<td height="221" width="221" bgcolor="#CC0000">Image will go here</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END BIG WRAPPER TABLE -->

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>