Underline text in HTML - 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

Related

HTML table rows with varying cell heights

I have an HTML table that's being filled with content of various sizes. Some can be about a paragraph long.
All I want to accomplish is to have the cells automatically adjust in height to support the various content, without giving each row a fixed size ('cause that would look bad).
<td align="left" width="10%" height="130"><div>{{this.val8}}</div></td>
<td align="left" height="130"><div>{{{this.val7}}}</div></td>
<td align="left" height="130"><div>{{this.val6}}</div></td>
<td align="left" height="130"><div>{{this.val}}</div></td>
<td height="130" width="80%"><div>{{{this.val0}}}</div></td>
<td height="130"><div>{{{this.val8}}}</div></td>
<td align="right" width="80%" height="130"><div>{{{this.val1}}}</div></td>
<td align="right" width="80%" height="130"><div>{{{this.val2}}}</div></td>
<td height="130" width="75%"><div>{{{this.val3}}}</div></td>
<td height="130"><div>{{this.val4}}</div></td>
<td height="130"><div>{{this.val5}}</div></td>
Right now, I have fixed heights for each cell. Generally, most cells fit this height, but I'd like the ones that don't to be smaller.
Any tips or suggestions would be awesome.
Thanks!
Lets clean up your markup for starters:
http://jsfiddle.net/x3a6bu7L/
<table>
<tr>
<td align="left">
{{this.val8}}
</td>
<td align="left">
{{this.val7}}
</td>
<td align="left">
{{this.val6}}
</td>
<td align="left">
{{this.val}}
</td>
<td>
{{this.val0}}
</td>
<td>
{{this.val8}}
</td>
<td align="right">
{{this.val1}}
</td>
<td align="right">
{{this.val2}}
</td>
<td>
{{this.val3}}
</td>
<td>
{{this.val4}}
</td>
<td>
{{this.val5}}
</td>
</tr>
</table>
You don't need those DIV elements inside the TD cells.
The settings for height were incorrect and not necessary. The
proper way to set height is height:130px if you really have to.
Your widths were incorrect. If you want to use percentages you need
all TD width percentages to add up to 100%
Don't use inline CSS. Use an external CSS stylesheet or encapsulate
all your styles in a STYLE element in the HEAD.
If you need to set vertical alignment for the cells use:
td { vertical-align:top; }
Just remove all height attributes. Also please note that both height and width attributes are obsolete - use styles instead.

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.

HTML - How to apply padding to a horizontal border?

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>

CSS Browser compatibility issues creating borders

HTML markup:
<table class='cardc'>
<tr>
<td rowspan='5' width='10%'>
<img src='http://fwfn.ca/sites/default/files/pictures/blank_person.jpg' height='120' width='100'/>
</td>
<td width='70%' colspan='3'>"
."<a href='".$profilePage."&sid=".$sfid."#box-one'>".($record->fields->FirstName)." ".($record->fields->LastName)."</a></font>
</td>
<td>
".$record->fields->Email."
</td>
</tr>
<tr>
<td class='greyF' colspan='3'>
".$record->fields->Country_of_Citizenship__c."
</td>
</tr>
<tr>
<td>
<div class='greyF'>year</div>".$record->fields->Fellowship_year__c."
</td>
<td>
<div class='greyF'>Organization</div>".$record->fields->Partner_Organization__c."
</td>
<td>
<div class='greyF'>Country</div>".$record->fields->Fellowship_Country__c."
</td>
</tr>
<tr>
<td colspan='3'>
<div class='greyF'>Education</div>".$record->fields->Education__c."
</td>
</tr>
<tr>
</tr>
</table>
CSS markup:
.cardc {
border: 5px outset white;
padding: 3px;
width:80%;
}
But as the title says, I'm having cross Browser issues, the border that's supposed to cover the whole table gets cut off at the bottom.
Any recommendations for alternative ways to create the border?
Edited HTML taking everybody's worries into consideration. Border still draws improperly.
See a demo here
It's caused by a combination of an invalid rowspan and border collapsing (which is the default when you select "Normalized CSS" in jsFiddle). If you turn that off or provide the correct number of rows then the border draws correctly.
<td rowspan='5' width=10%> indicates that there are at least 4 following rows, since the current cell shall span 5 rows. Since you don't provide any of those rows the <td> will spill out of the table. Drop the rowspan attribute:
<td style="width:10%">
<img src='http://fwfn.ca/sites/default/files/pictures/blank_person.jpg' height='120' width='100'/>
</td>
You have a rowspan="5" on the first td which is breaking the bottom border of the table, probably because it cannot find the remaining 4 rows to merge with. Removing the rowspan fixes the border.
http://jsfiddle.net/Q3e9m/
Try fixing the errors with html in your code, for starters. Your code lacks some quotation marks, and styling attributes in tags are deprecated.
<html>
<head>
<style>
.cardc {
border: 5px outset white;
padding: 3px;
width:80%;
}
</style>
</head>
<body>
<table class='cardc' style="height:100px;">
<tr>
<td style="width:10%">
<img src='http://fwfn.ca/sites/default/files/pictures/blank_person.jpg' style="height:120px;width:100px;"/>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</body>
Lack of quotation marks and units.you need to specify whether your values are in pixels or ems ....try and use color coding codes, eg #fff or rgb(255 255 255) instead of of saying white.

Table border size - CSS/HTML

Is it possible to extend a cell's border width/height so that it joins with the border of surrounding table?
I have this:
<table width="270px" style="border: 1px;">
<tbody width="270px">
<tr>
<th colspan="3" style="border: 1px;">
Header
</th>
</tr>
<tr>
<td style="border: 1px;" valign="middle">
Left-hand cell
</td>
<td valign="middle">
Right-hand cell
</td>
<td>
Left-hand cell
</td>
</tr>
</tbody>
</table>
What is happening is the inner borders don't meet the outer border - there is a slight gap.
Can I get these border to meet?
Have a look at CSS border-collapse.
table
{
border-collapse: collapse;
}
Also, have a look at this answer on how to achieve cellpadding and cellspacing in CSS.
From Ant P.'s answer:
... just for completeness:
padding → cellpadding
border-spacing → cellspacing
border-collapse → no HTML equivalent
It's also worth remembering that you can set separate horizontal and vertical values for the CSS ones e.g. border-spacing: 0 1px.
Try this and let me know:
<table width="270px" style="border: 1px;" cellspacing="0" cellpadding="0">
<tbody width="270px">
<tr>
<th colspan="3" style="border: 1px;">
Header
</th>
</tr>
<tr>
<td style="border: 1px;" valign="middle">
Left-hand cell
</td>
<td valign="middle">
Right-hand cell
</td>
<td>
Left-hand cell
</td>
</tr>
</tbody>
</table>