I am making an HTML Email and have decided to use tables for each of the nav elements. I need the tables to be displayed inline. I used display:inline-block; on the table creating the desired result,
However the TEXT inside the table will not align. I have placed the text-align: center; in the table, td, and a tag but it has not worked.
I know the method works with divs but I can't find a solution for tables.
HTML
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" valign="top">
<table class="navInline" width="130" height="35" border="0" cellspacing="0" cellpadding="0" bgcolor="#999966" style="text-align:center;">
<tr>
<td align="center"> <a href="#" style="text-decoration: none; color: #005E82;">
option 1
</a>
</td>
</tr>
</table>
<table class="navInline" width="130" height="35" border="0" cellspacing="0" cellpadding="0" bgcolor="#999966">
<tr>
<td align="center" style="text-align:center;"> <a href="#" style="text-decoration: none; color: #005E82;">
option 2
</a>
</td>
</tr>
</table>
<table class="navInline" width="130" height="35" border="0" cellspacing="0" cellpadding="0" bgcolor="#999966">
<tr>
<td align="center"> <a href="#" style="text-decoration: none; color: #005E82; text-align:center;">
option 3
</a>
</td>
</tr>
</table>
</td>
</tr>
CSS
.navInline {
display:inline-block;
vertical-align:top;
text-align: center !important; }
here is the not working code
http://jsfiddle.net/nathanaric/pf35h/9/
You need to set a width attribute on your table cells.
Example:
<table class="navInline" width="130" height="35" border="0" cellspacing="0" cellpadding="0" bgcolor="#999966" style="text-align:center;">
<tr>
<td align="center" width="130">option 1</td>
</tr>
Can't say I agree with the chosen answer about adding width.
Your issue is the inline-block attribute. It's affecting all the user-agent defaults of the table child elements. Simply, replace display:inline-block with float:left and you get the same results with all the other css stlying falling into place. (text align e.g.)
.navInline {
float:left;
vertical-align:top;
text-align: center !important;
}
Here is a fiddle applying the new style.
http://jsfiddle.net/bdTUz/
BUT IMPORTANTLY... Your question states you are making an email template. Classes may not work. What I know from making html based emails, best practices are to add inline styles.
This link may be very helpful
http://htmlemailboilerplate.com/
I was able to resolve your issue using a list and not using any DIVs. It's much cleaner. Working code can be found in this JSFiddle:
HTML
<ul class="navInline">
<li>option1</li>
<li>option2</li>
<li>option3</li>
</ul>
CSS
.navInline li {
display:inline-block;
list-style:none;
border: 1px solid #333;
padding: 5px;
background-color: yellow;
}
Related
Below is the html page.
There is a dynamic url variable which will generate the tag.
As there are other static tag, the whole css for tag is applying to all of those links.
How can I control dynamic variable which will generate the tag using css?
I tried to put that variable insides tags and not working. Any idea?
a { color: #f05322;
text-decoration: underline;
}
a:hover { color: #f05322;
text-decoration: underline;
}
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" style="" bgcolor="#ffffff">
<tbody>
<tr height="0" style="padding:0px;vertical-align:top">
<td height="0" style="padding:0px;">
<table style="width:900px; margin:auto;" align="center" border="0" cellpadding="0" cellspacing="0" width="900">
<tbody>
<tr>
<td style="padding:20px 10px 10px 35px; " bgcolor="#E6E6E6">
<font face="Arial, Helvetica, sans-serif" style="font-size:14px; color:#3A393A;"> © test | www.test.com</font>
</td>
</tr>
<tr>
<td>
${someURL}
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Easiest is to add a class to the parent (td):
<td class="someClass">
${someURL}
</td>
.someClass a {
background: yellow;
}
JSFiddle
When you're unable to change the structure you can target that cell with this CSS:
table table tr:nth-of-type(2) a {
background: yellow;
}
JSFiddle
Please note that option is the cleanest solution... if you drastically change your structure, you'll need to change option 2 too.
I am trying to create a single page, will be used as a newsletter, so my code is html/css inline.
http://jsfiddle.net/Chamberja/6t9r14ew/
I want to add a background image behind that entire table so the logo and the text will appear in the foreground.
I have tried adding
style="background-image: url("bg.jpg")"
and
style= "background: url(bg.jpg)"
So the final code looks like
<table style="background: url(sportip.biz/alpha.jpg)" border="0" cellpadding="0" cellspacing="0" align="left" class="deviceWidth">
<tr>
<td style="padding:10px 20px" class="center">
<img src="http://sportip.biz/nlsiplogo.jpg" alt="" border="0" />
</td>
</tr>
</table>
I think I am doing the in-line wrong.
I hope this is what you looking for:
<table style="background: url(sportip.biz/alpha.jpg)" border="0" cellpadding="0" cellspacing="0" align="left" class="deviceWidth">
<tr>
<td style="padding: 10px 20px" class="center">
<img src="http://sportip.biz/nlsiplogo.jpg" alt="" border="0" />
</td>
</tr>
</table>
<!-- End Logo -->
<!-- Nav -->
<table style="position: absolute; margin-top: 0; margin-left: 0;" border="0" cellpadding="0" cellspacing="0" align="right" class="deviceWidth">
<tr>
<td class="center" style="font-size: 13px; color: #272727; font-weight: light; text-align: right; font-family: Georgia, Times, serif; line-height: 20px; vertical-align: middle; padding:10px 20px; font-style:italic">
<b>Dear #name#,
Check out the latest releases of our magazines</b>
</td>
</tr>
</table>
Here's the fiddle.
jsfiddle.net/shanidkv/g0dd3vcm/1/
Find the updated JSfiddle code.
Note: Try to copy and past above url to browser facing some problem to attach link directly or on top of text
Many email clients do not support rendering a background image inside a table. See here for some examples of workarounds: http://blog.mailermailer.com/email-design/background-images-in-html-email-the-naked-truth
I'm making an email HTML document for my company
Everything is fine other than a set of images that are meant to appear.
On Office they appear just fine but on Gmail the are hidden and when i look at the HTML in inspector i see that the style="display: none !important; visibility: hidden !important; opacity: 0 !important; background-position: 300px 32px;" has been added to the image.
Does anybody know why this is and how i can stop it.
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff">
<tr>
<td width="100%">
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 1px solid #45b75c;">
<tr style="border: 1px solid #45b75c">
<td align="center" width="155" height="155" style="background-color: #f3f1f1;">
<img src="https://www.soccerhubb.com/assets/img/emails/world-cup/advert1.png" width="115" height="115" alt="Advertise to your target audience" line-height="" style="display: block;"/>
</td>
<td align="center">
<p style="text-align: center; font-size: 24px; color: #45b75c;">
Advertise to your target audience<br />
with intelligent analytics
</p>
</td>
</tr>
</table>
</td>
</tr>
<table>
Use style tag and apply style with display:block !important
In css !important keyword use for overwrite all style
Never mind i found out the issue.
As my image was called "advert1" spam filters caught it and assumed other content in the same table was also spam
note to self: don't use "advert" in alt tags or image names
I have a HTML newsletter table, to structure the content I want horizontal borders. Somehow the horizontal borders always have 100% width according to the table width. How can I achieve 20px padding to the left and right of it?
js fiddle
HTML
<table border="1" cellpadding="0" cellspacing="0" align="center" width="400">
<tr>
<td >Banana
</td>
</tr>
<tr style=" padding: 0 20px 0 20px;">
<td style=" padding: 0 20px 0 20px; border-bottom: 3px solid red;">
</td>
</tr>
<tr>
<td >Apple
</td>
</tr>
</table>
you can't able to do what you want in current code
you need to do some trick
see this
<table border="0" cellpadding="0" cellspacing="0" align="center" width="400">
<tr>
<td >Banana
</td>
</tr>
<tr >
<td> <hr style=" border:0px; margin: 0 20px 0 20px; border-bottom: 3px solid red;">
</td>
</tr>
<tr>
<td >Apple
</td>
</tr>
</table>
i have used (HR) tag in 2nd table row, this will solve your problem ☺
A border does not take padding into account, but it does with margin. See the CSS Box Modell for reference.
On CSS, there is the cascade. It parses top-dowmn and specific overrides general
There are many ways to achieve what you want (including ways in which we have to change the HTML code). Suppose you want to keep the table layout. You can just set the border-left and border-right of the middle td like this:
tr.hr > td {
border:none;
border-left:20px solid white;
border-right:20px solid white;
background:red;
height:3px;
}
HTML:
<tr> <td> Banana </td> </tr>
<tr class='hr'> <td></td></tr>
<tr> <td> Apple </td> </tr>
Demo.
Note that the color of border-left and border-right should be the same to the background color of your table. (they are all white in the demo).
Please have a look at the HTML email boilerplate.
http://htmlemailboilerplate.com/#f1
Limitations using CSS: http://www.campaignmonitor.com/css/. It solves may issues with ie. spacing amongst others and email clients rendering issues (Gmail, Outlook,Yahoo, ...)
HTML emails need to respect 600px width as it is a default for the preview.
To test the HTML email (if no mail configured on a testing server) you could use http://putsmail.com/ Check also on smart phone as many people tend to read mail on it
You can achieve the effect using a combination of 3 cells where the first and last use spacers and the middle can be a red solid color gif.
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td valign="top" width="20"><img width="20" height="3" src="transparent.gif" alt="" /></td>
<td valign="top" width="560">
<img src="red.gif" width="560" height="3" alt="" />
</td>
<td valign="top" width="20"><img width="20" height="3" src="transparent.gif" alt="" /></td>
</tr>
</table>
I want to have in a, e-mail that I code in HTML, a div with two colors and a text in span.
I have coded this:
<div class="msg" style=" width: 500px; background-color: gray; position: relative;">
<span class="text" style="font-size: 11px; color: white; position: absolute; bottom: 5px; left: 1%;">A text in a span.</span>
<div class="refus" style="width: 50%; height: 25px; background-color: #EF4135"></div>
</div>
You can find a demo here:
http://jsfiddle.net/aWvcp/2/
The problem is, in an mail tool like Thunderbird, it's working but not in outlook.
Is it possible to have the same render but for compatible with Outlook?
To ensure strictest adherence to your design, I would avoid <DIV>s, CSS position statements and spans. Be as regimented as possible with tables, inline margin tags and <p> with inline style. See a recreation of what you wanted in JSfillde.
It is hard to tell exactly what you are after, but here is an example in proper html email format:
<table width="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" bgcolor="#EF4135" valign="bottom" style="font-size: 11px; color: white; padding:1%; padding-bottom:5px;">
First column<br>...<br>...
</td>
<td valign="top" width="50%">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" bgcolor="#818181">
</td>
</tr>
</table>
</td>
</tr>
</table>