HTML - How to apply padding to a horizontal border? - html

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>

Related

send image to the bottom of a td with valign="top" property

I'm having so much problems trying to send an image to the bottom of a td. The problem is that
the td needs to have the valign="top" property.
<html height="100%">
<table height="100%" width="100%">
<tr>
<td height="10%" valign="top" style="background-color: black"> </td>
</tr>
<tr>
<td height="80%" valign="top" style="background-color: grey">
Website content..
<img style="position:absolute; right:10px; bottom: 10px " height="45" width="45" src="http://rsm.imap.cc/-images/rss.jpg"></img>
</td>
</tr>
<tr>
<td height="10%" valign="top" style="background-color: black"> </td>
</tr>
</table>
</html>
The most close that I've got is to send the image to the bottom of the website, but this is not what I want to do, the image should remain on the grey background. (the second td)
Try this: put position: relative; on the <td>, then position: absolute; on the <img> and give it a bottom: 0;.
Then you'll also need to set a padding-bottom: <height-of-image>px; on the <td> to prevent the image from going over the text.

Removing all borders from HTML table

I've tried everything I can find so far in other stack overflow questions to solve this issue but can't get it figured out. I've got an HTML table with background images that I'm using to create rounded dividers/bubbles around specific items on a website. I can't get the table rows to completely go away though. And it seems like they are only to top and right that are showing a division? Both CSS and the table are shown below. Here's an image of what I can't get rid of. You can see the thin line right under the curves down then along the right side of the right border. It shows up other places too but the background is so close to the border color that it's not noticeable.
Also there is some redundant CSS in there I've just been trying everything I can find/think of in order to fix is.
I can't add images but here's a link with the image of the result I keep getting http://www.bdtransport.com/devel/TableIssue.JPG
Code:
table {
border-collapse: collapse;
border-spacing: 0;
border: none !important;
padding: 0 0 0 0;
margin: 0 auto;
}
tr, td {
padding: 0 0 0 0;
spacing: 0
border: none !important;
outline: none;
border-collapse: collapse;
}
<TABLE width='1100' align='center'>
<TR>
<TD colspan='5' background='./images/MainTop.jpg'> </TD>
</TR>
<TR>
<TD background='./images/MainLeft.jpg' width='75'> </TD>
<TD background='./images/MainNewsBackground.jpg' width='687'> Text </TD>
<TD background='./images/MainNewsDivider.jpg' width='22'> </TD>
<TD background='./images/MainNotificationsBackground.jpg' width='250'> Recent/Upcoming Info: </TD>
<TD background='./images/MainRight.jpg' width='66'> </TD>
</TR>
</table>
Please note that the following code snippet has been edited to include border="0" in the table opening. This should remove all borders.
<TABLE width='1100' align='center' border="0">
<TR>
<TD colspan='5' background='./images/MainTop.jpg'> </TD>
</TR>
<TR>
<TD background='./images/MainLeft.jpg' width='75'> </TD>
<TD background='./images/MainNewsBackground.jpg' width='687'> Text </TD>
<TD background='./images/MainNewsDivider.jpg' width='22'> </TD>
<TD background='./images/MainNotificationsBackground.jpg' width='250'> Recent/Upcoming Info: </TD>
<TD background='./images/MainRight.jpg' width='66'> </TD>
</TR>
</table>
If that did not remove all borders, you can try:
<TABLE width='1100' align='center' style="border:0">
<TR>
<TD colspan='5' background='./images/MainTop.jpg'> </TD>
</TR>
<TR>
<TD background='./images/MainLeft.jpg' width='75'> </TD>
<TD background='./images/MainNewsBackground.jpg' width='687'> Text </TD>
<TD background='./images/MainNewsDivider.jpg' width='22'> </TD>
<TD background='./images/MainNotificationsBackground.jpg' width='250'> Recent/Upcoming Info: </TD>
<TD background='./images/MainRight.jpg' width='66'> </TD>
</TR>
</table>
That should remove the border. With this method, there is also no need for overly complicated CSS code in your page.

Underline text in HTML

I want to write the simpliest example of the following image
My example should work in ie6,7,8,9 and so on. So I can't use float or anything helpfull. I made jsFiddle using table
<table width="500px">
<tr>
<td width="45px"><span>e-mail</span>
</td>
<td align="center"> <div style="border-bottom: 1px solid;">test#gmail.com</div></td>
</tr>
<tr>
<td width="45px"></td>
<td align="center"> <span>(email)</span>
</td>
</tr>
</table>
, but the bottom (email) have margin from the line.
And I want that everything was like on my first image. Thanks
I have tried this.
Check this jsFiddle link
<table width="500px" style="padding:0px; border-spacing:1px">
<tr>
<td width="45px" style="padding:0px"><span>e-mail</span>
</td>
<td align="center" style="padding:0px"> test#gmail.com <hr noshade style="border-top:1px; -webkit-margin-before: 0; -webkit-margin-after: 0; -webkit-margin-top: 0; -webkit-margin-bottom: 0;"/> </td>
</tr>
<tr>
<td width="45px" style="padding:0px"></td>
<td align = "center" style = "margin-top:0px; padding:0px">(email)</td>
</tr>
The “margin” you are referring to is partly spacing between cells, partly padding inside the cell, partly leading, and partly spacing in the font. In your approach, the simplest fix is probably to set cell spacing to zero and to move the cell content upwards a bit, using relative positioning.
<table width="500" cellspacing="0">
<tr>
<td width="45">e-mail
</td>
<td align="center" style="border-bottom: 1px solid">test#gmail.com</td>
</tr>
<tr>
<td width="45"></td>
<td align="center"><span style="position: relative; top: -0.15em">(email)</span>
</td>
</tr>
</table>
apply border-spacing: 0 to the table's style (border-collapse: collapsewould work too, aswell as cellspacing attribute)
add padding: 0 to the tdcontaining <span>(email)</span>
To increase the space between the upper e-mail-adress and the bottom border (which you did not mention explicitly but is not the same as your example image):
move the border-bottom style from div to its parent td
add a padding-bottom to the same td

Outlook Border not resolving

I'm trying to make a HTML email template (difficult at the best of times) and I am trying to have a double line between the header and content. I'm trying to use border styles to achieve this like so:
<div class="1"> header image </div>
<div class="2"> random text </div>
using a head style sheet:
.1 {
margin:0;
padding: 0;
border-bottom:thin solid red;
}
.2 {
margin:0;
padding: 0;
border-top:thin solid yellow;
}
it seems to work fine in WLM and other email clients, but not outlook.
In my experience working with email HTML and Outlook, I find I always come back to using tables for layout. The many different email clients do many weird things to HTML, but table layouts seem to be the most cross-client compatible. So, consider something like this:
<table cellpadding="0" cellspacing="0" width="100%" style="border-bottom: solid 1px red;">
<tr>
<td> header image </td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" style="border-top: solid 1px yellow;">
<tr>
<td> random text </td>
</tr>
</table>
I haven't tested this, but it's what I'd try first.
Oke to sart with, the easiest way to make a nice e-mail template is with tables ( not sure if you use them. Try to link as less as possible to your css but do style="" as much as possible.
And take a look at this one :OVER HERE! this one helped me out alot
I would suggest you use inline CSS for the border style and hex values for the color. I have changed your code to old school CSS. Tried and tested on Litmus
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="ffffff">
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="50%" style="border-bottom: solid 1px #ff0000;">
<tr>
<td> header image </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="line-height: 20px; font-size: 20px;"> </td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="50%" style="border-top: solid 1px #ffff00;">
<tr>
<td> random text </td>
</tr>
</table>
</td>
</tr>
</table>

curved bordered CSS for IE8

I need curved bordered CSS for IE8 and all major browsers. currently I am trying with CSS PIE
jsfiddle demo is here. But I would suggest the answerers to download the PIE.htc file form here and try the HTML as a standalone page to get the real effect in IE8.
My problem is the <td> containing the "Thank you for registering" text is not curving in IE8 in jsfiddle. If I run it as a HTML page, it is curving in IE8 but the blue background is overlapping the "Thank you for registering" <td> (but its background is "#f2f2f2").
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin:0px; padding:0px;">
<tr>
<td> </td>
<td style="width: 60%; text-align: center;background: #0067C8;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td colspan="3" style="height: 50px; background-color: #262626; width:100%; text-align: left;">
<img src="twitter_logo.png" width="200" height="50" alt"Twitter" />
</td>
</tr>
<tr>
<td colspan="3" style="height: 25px;"> </td>
</tr>
<tr>
<td style="width:3%;"> </td>
<td style="width: 94%; background-color: #f2f2f2; height: 400px; font-family: arial; font-size: 30px; color: #2DB8ED; text-align: center; border: 2px solid #bcbcbc;text-align: center;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px; behavior: url(PIE.htc);">
Thank you for registering
</td>
<td style="width:3%;"> </td>
</tr>
<tr>
<td colspan="3" style="height: 25px;"> </td>
</tr>
</table>
</td>
<td> </td>
</tr>
</table>
I think its mainly because of Problems with z-index.
Check here for more details. general issues encountered when using PIE
Have you tried, http://jquery.malsup.com/corner/ jquery plugin to add curves?
$(function () {
$('table table tr:eq(2) td:eq(1)').corner();
});
Demo : http://jsfiddle.net/bDvRd/4/
Try add
position:relative;
z-index: 0;
by Using CSS3Pie htc for border-radius in IE8
OR CSS3 PIE - Giving IE border-radius support not working?