Table cell image is not displaying - html

Table cell image and cell background image is not displaying:
<table border="1">
<colgroup>
<col width="150"/>
<col width="350"/>
</colgroup>
<tbody>
<tr>
<td height="100%" width="92%"><image src="../images/refresh.jpg" alt="Test"></td>
<td background="https://media.giphy.com/media/10S1CGpBU06FZ6/giphy.gif" width="8%"></td>
</tr>
</tbody>
</table>

Just try this.
<table border="1">
<colgroup>
<col width="150"/>
<col width="350"/>
</colgroup>
<tbody>
<tr>
<td height="100%" width="100%"><img src="../images/refresh.jpg" alt="Test"></td>
<td style="background:url(../images/refresh.jpg);" width="100%"></td>
</tr>
</tbody>
</table>
Since it is img not image and TD element dosn't have the background attribute, you can put your custom style inside the style attribute just like above.

Try using this:
<td style="background-image: url('../images/refresh.jpg')" width="100%">
Also, it's probably pretty likely that your path is incorrect. Try inserting:
<?php if(file_exists("../images/refresh.jpg")){
echo "IT EXISTS!";
}
else{
echo "NOT FOUND!";
}
?>
That should tell you if your path is correct or not.

<image> is not a tag, it is abbreviated the to <img>, so it should be something like this: <**img** src="../images/refresh.jpg" alt="Test">.
In the following example I added an image from the net to show you:
td {
border: solid 1px black
}
<table border="1">
<colgroup>
<col width="150" />
<col width="350" />
</colgroup>
<tbody>
<tr>
<td height="100%" width="100%"><img src="http://lorempixel.com/400/200" alt="Test"></td>
<td style="background:url(../images/refresh.jpg);" width="100%"></td>
</tr>
</tbody>
</table>
Hope it helped.

You are probably not seeing anything since the first td is 100%.
Change the first td to take up 92% or anything less than 100% of the width.
<td height="100%" width="92%"><image src="../images/refresh.jpg" alt="Test"> </td>
<td background="../images/refresh.jpg" width="8%"></td>
<table border="1">
<colgroup>
<col width="150"/>
<col width="350"/>
</colgroup>
<tbody>
<tr>
<td height="100%" width="92%"><image src="../images/refresh.jpg" alt="Test"></td>
<td background="https://media.giphy.com/media/10S1CGpBU06FZ6/giphy.gif" width="8%"></td>
</tr>
</tbody>
</table>

Related

How to fixed the td width in table

I use easyui-panel with one table in my project.
I want to fixed each td width:50px;
Here is my code:
<div class="easyui-panel" id="pp" style="margin-top:30px;width:100%">
<table class="uTbId" cellspacing="0" style="width:100%" >
<tr>
<td style="position:absolute;width:50px;background-color:#fafafa">stack</td>
<td style="position:absolute;width:50px;background-color:#fafafa">john</td>
<td style="position:absolute;width:50px;background-color:#fafafa">stock</td>
<td style="position:absolute;width:50px;background-color:#fafafa">shansa</td>
</tr>
<tr>
<td style="postion:absolute;width:50px;background-color:#fafafa">Joy</td>
</tr>
</table>
</div>
But it works fail. stack,john and stock are disappear. My table is in an abnormal stat.
When I deleted "position:absolute;width:50px;", all names can be show.like:
<div class="easyui-panel" id="pp" style="margin-top:30px;width:100%">
<table class="uTbId" cellspacing="0" style="width:100%" >
<tr>
<td style="background-color:#fafafa">stack</td>
<td style="background-color:#fafafa">john</td>
<td style="background-color:#fafafa">stock</td>
<td style="background-color:#fafafa">shansa</td>
</tr>
<tr>
<td style="background-color:#fafafa">Joy</td>
</tr>
</table>
</div>
All names can appear without fixed width, but it is not what i want.
Who can help me ?
You don't need to remove both position:absolute and width:50px.
Removing position:absolute and the width:100% from the <table> should result in what you want. So now your HTML looks like
<div class="easyui-panel" id="pp" style="margin-top:30px;width:100%">
<table class="uTbId" cellspacing="0">
<tr>
<td style="width:50px;background-color:#fafafa">stack</td>
<td style="width:50px;background-color:#fafafa">john</td>
<td style="width:50px;background-color:#fafafa">stock</td>
<td style="width:50px;background-color:#fafafa">shansa</td>
</tr>
<tr>
<td style="width:50px;background-color:#fafafa">Joy</td>
</tr>
</table>
If it doesn't result in what you want, it is possible that some CSS styles are adding additional padding or margins to the <td> element. Fire up the developer console (F12 on most browsers) -> right click on your element -> Inspect and in the CSS styles part look at the box model to find out if there is any additional padding/margins being applied
You can set your HTML talbe to be fixed width, then specify column widths:
<div class="easyui-panel" id="pp" style="margin-top:30px;width:100%">
<table class="uTbId" cellspacing="0" style=" table-layout:fixed;" >
<col width="5px" />
<col width="5px" />
<col width="5px" />
<col width="5px" />
<col width="5px" />
<tr>
<td style="background-color:#fafafa">stack</td>
<td style="background-color:#fafafa">john</td>
<td style="background-color:#fafafa">stock</td>
<td style="background-color:#fafafa">shansa</td>
</tr>
<tr>
<td style="background-color:#fafafa">Joy</td>
</tr>
</table>
</div>
https://jsfiddle.net/56Lc4o44/
When I use unified format, It works OK
The code is:
<style>
.uTbId tr td{width:100px;background-color:#fafafa}
.uTbId tr td:hover{background-color:#0000CD;color:green;}
</style>
<div class="easyui-panel" id="pp" style="margin-top:30px;width:100%">
<table class="uTbId" cellspacing="0" style="width:100%" >
<tr>
<td >stack</td>
<td >john</td>
<td >stock</td>
<td >shansa</td>
</tr>
<tr>
<td>Joy</td>
</tr>
</table>

gmail stripping inline css from table

I have the following html that works in MS Mail, outlook, ios but not with gmail. I thought placing the css as inline would fix the problem but it doesn't. The two problems are the text size appears too big. I'm wondering if there is a way to have gmail use a different font size then the other email clients. Also I need a blank line in the table and use &nbsb inside a but this appears as just &nbsb text in gmail.
UPDATE: fixed the &nbsp with But fontsize even with !important not working. It seems in gmail the margin:0 auto for the table is not working in gmail
<!DOCTYPE html>
<html>
<header>
</header>
<body lang=EN-US>
<div style="text-align:center;margin:0 auto;font-size:5vw">
<img src="cid:swb-image">
<h3 style='padding-left:10px;margin-bottom:0;margin-top:0%;padding-top:0;text-align:left'> Hi firstname, </h3>
<table style='text-align:left;margin:0 auto;' >
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<col style='width:6%'>
<tr>
<td colspan='12' style='text-align:center'><h3 style='margin-top:8px;margin-bottom:0'> msg1</h3><h4 style='margin-bottom:8px;margin-top:0'>msg2 </h4></td>
</tr>
<tr>
<td colspan='3'>DATE:</td>
<td colspan='9'>datex</td>
</tr>
<tr>
<td colspan='3'>SKIPPER:</td>
<td colspan='9'>skipperx</td>
</tr>
<tr>
<td colspan='3'>BOAT:</td>
<td colspan='9'>boat</td>
</tr>
<tr>
<td colspan='3'>STATUS:</td>
<td colspan='9' style='color:colorx'>status</td>
</tr>
<!--<tr><td>&nbsp</td></tr> -->
<tr>
<td colspan='4'>&nbsp</td>
<td colspan='4' style='text-align:center;'>Start</td>
<td colspan='4' style='text-align:center;'>END</td>
</tr>
<tr>
<td colspan='4'>ressailxcl:</td>
<td colspan='4' style='font-weight:bold;text-align:center'>start</td>
<td colspan='4' style='font-weight:bold;text-align:center'>end</td>
</tr>
<tr>
<td colspan='12' style='text-align:center'><h5 style='margin-bottom:1%;'>Click on link to update your availability</h5></td>
</tr>
<tr>
<td colspan='4' style='text-align:left;'><a style='text-decoration:none;' href='mailto:skipemail'>
<img src="http://www.sailwbob.com/skipper/public/img/email-32.png" style="width:32px;height:32px;border:0;"></a></td>
<td colspan='4' style='text-align:center;'><h5> <a href='http://www.sailwbob.com/skipper'>SwB link</a></h5></td>
<td colspan='4' style='text-align:right';><a style='text-decoration:none' href='tel:skipphone'>
<img src="http://www.sailwbob.com/skipper/public/img/phone-32.png" style="width:32px;height:32px;border:0;"></a></td>
</tr>
</table>
</div>
<div>
<!--skipmsg-->
</div>
</body>
</html>
so the problem was really just:
font-size:5vw;
In gmail it's just too large but in other places the 5vw was working just fine.
The solution, within style tags I added:
font-size:5vw!important
and in the inline css for the div changed the size to 16px. So, in browsers that need the 5vw (they accept the style tag) they get that size and in places that don't accept the style tags they get 16px. Ugly, but it works

Table import from Excel formatting weird. Aligning different than other table

I am re-doing my high school track/cross country website. I have downloaded the files that were used in the original site and I am having issues with table formatting. Here is a pic:
You can see that the bottom table is spaced out much nicer than the top. I am sure there is a small line that I need to change but after a while of messing with stuff I can't seem to get it to work. Here is the HTML for the top (bad) table
<table frame="void" cellspacing="0" cols="5" rules="none" border="0">
<colgroup>
<col width="334" />
<col width="300" />
<col width="116" />
<col width="110" />
</colgroup>
<tbody>
<tr>
<td colspan="5" width="775" height="30" align="center" sdnum="1033;0;#"><strong>Shepherd High School Boys Outdoor Track Records</strong></td>
</tr>
<tr>
<td align="left" sdnum="1033;0;#"> </td>
<td height="22" align="left" sdnum="1033;0;#"><strong>Event</strong></td>
<td align="left" sdnum="1033;0;#"><strong>Name</strong></td>
<td align="center" sdnum="1033;0;#"><strong>Record</strong></td>
<td align="center" sdnum="1033;0;#"><strong>Date</strong></td>
</tr>
Here is the HTML for the good table
<table frame="void" cellspacing="0" cols="4" rules="none" border="0">
<colgroup>
<col width="334" />
<col width="300" />
<col width="116" />
<col width="110" />
</colgroup>
<tbody>
<tr>
<td colspan="5" width="775" height="30" align="center" sdnum="1033;0;#"><strong>Shepherd High School Boys Outdoor Track Records</strong></td>
</tr>
<tr>
<td height="22" align="left" sdnum="1033;0;#"><strong>Event</strong></td>
<td align="left" sdnum="1033;0;#"><strong>Name</strong></td>
<td align="center" sdnum="1033;0;#"><strong>Record</strong></td>
<td align="center" sdnum="1033;0;#"><strong>Date</strong></td>
</tr>
They are the same but they end up very different. Is there something in there that is messing with the layout? If you need anything else I will be glad to add it. Thank you.

Colspan sizing not working

When I run the code below, the proportions are all off. What do I need to change to get the right spacing? The columns on the bottom labeled 2 are about 4/5ths the size of the ones on top marked 4.
<body bgcolor="#14B3D9">
<table width="100%" border="1" bgcolor="#ffffff">
<colgroup> <!-- Sets up table for spacing -->
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
</colgroup>
<tr>
<td colspan="4">4</td>
<td colspan="2">2</td>
<td colspan="4">4</td>
</tr>
<tr>
<td colspan="10">10</td>
</tr>
<tr>
<td colspan="5">5</td>
<td colspan="5">5</td>
</tr>
<tr>
<td colspan="2">2</td>
<td colspan="6">6</td>
<td colspan="2">2</td>
</tr>
</table>
</body>
The table markup violates the HTML table model, as you can see by using http://validator.org on the markup with HTML5 as the selected version; it says e.g. “Table column 2 established by element col has no cells beginning in it.” This means that anything may happen.
You should correct the markup so that for each column, there is at least one cell that begins in it, as required by the table model. Alternatively, as this seems to be an attempt at complicated layout with table, rather than tabular data, consider other options such as CSS layout.

HTML table column of equal size

With the below code, I get the columns size being different (esp the last column is small) I would like to have all the three columns to be of same size.Thanks.
<html>
<body>
<h4>Two rows and three columns:</h4>
<table border="1" width="100%" height="400" align="top">
<tr style="height: 1">
<td>
<table width="100%" border="2" height ="100" align="top">
<tr>
<td>1-1</td>
<td>1-2</td>
</tr>
<tr>
<td>1-3</td>
<td>1-4</td>
</tr>
</table>
</td>
<td>
<table width="100%" border="2" height ="100" align="top">
<tr>
<td>2-1</td>
<td>2-2</td>
</tr>
<tr>
<td>2-3</td>
<td>2-4</td>
</tr>
</table>
<td>
<table width="100%" border="2" height ="100" align="top">
<tr>
<td>3-1</td>
</tr>
<tr>
<td>3-2</td>
</tr>
</table>
</td>
</tr>
<tr style="vertical-align: top">
</td>
<td>
<table width="100%" border="2" height ="100">
<tr>
<td>4-1</td>
<td>4-2</td>
</tr>
<tr>
<td>4-3</td>
<td>4-4</td>
</tr>
</table>
<td>
<table width="100%" border="2" height ="100">
<tr>
<td>5-1</td>
<td>5-2</td>
</tr>
<tr>
<td>5-3</td>
<td>5-4</td>
</tr>
</table>
<td>
<table width="100%" border="2" height ="100">
<tr>
<td>6-1</td>
</tr>
<tr>
<td>6-3</td>
</tr>
</table>
</body>
</html>
Insert a colgroup element in your table:
<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<tr>
...
</tr>
</table>
Few fixes to consider
<table style="table-layout: fixed; width: 100%;"> <!- set table layout to fixed and width to full width -->
<colgroup>
<col style="width: auto" /> <!- takes the remaining space -->
<col style="width: 33.3333%" /> <!- or use 33.3333% for all instead if you want to occupy full width -->
<col style="width: 33.3333%" />
</colgroup>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
...
</table>
Just set each <td> of the first level table to width="33%"
You could try to set your the width of your columns to be absolute, instead of relative:
< TD WIDTH=200>
Try looking at this link.
An alternative is to set the css width of the table to 100% e.g.
table { width:100% }
The cells should inherit this and be of equal size. That way you are more flexible to different numbers of columns.