Why is my table heading pushing the table rows out of place? - html

Without a heading, my table looks fine and normal. I tried adding a table heading and it pushed everything out of place. Could anyone tell me how to avoid this?
Relevant code:
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="white">
<th width="80%"> Let's talk about the wall </th>
<tr>
<td width="6%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td>
<td width="75%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td>
<td width="19%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td>
</tr>
And then:
<tr>
<td bgcolor="white"><font face="arial"></font></td>
<td bgcolor="white"><font face="arial"><? echo $rows['topic']; ?><BR></font></td>
<td align="center" bgcolor="white"><font face="arial"></font></td>
</tr>
To be clear, the text you see such as 'test,' 'slaaa,' etc. - I want that to be aligned much farther to the left of where it sits, which is how it sits when I have the table without a heading.

You're missing a tr wrapping the th, and a colspan
th {
background: #ccc;
}
td {
background: #aaa;
}
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="white">
<tr>
<th colspan="3"> Let's talk about the wall</th>
</tr>
<tr>
<td width="6%" align="center" bgcolor="white">
<strong>some text</strong>
</td>
<td width="75%" align="center" bgcolor="white">
<strong>Column 2</strong>
</td>
<td width="19%" align="center" bgcolor="white">
<strong>Column 3</strong>
</td>
</tr>

Related

Extra HTML Table cell appearing under table only on print/print preview

screenshot of issue When I print my document every table prints an extra cell right under the table (but just one). I have looked everywhere on the net to find a solution. So far, I haven't been able to find it. I'm using Chrome. I haven't tried anything significant because I can't find the issue on the internet yet. Maybe it is just me. please help.
Here is my code:
<style>
body {padding: 0px;
margin: 0px;
text-align: center;}
.noborder th {font-weight: bold;
border: none;
padding: 0px, 3px;}
.noborder td {font-weight: regular;
border: none;
padding: 0px, 3px;}
table.border {empty-cells:show;}
.border th {font-weight: bold;
padding: 0px, 3px;}
.border td {font-weight: regular;
border: 1px solid gray; }
</style>
<table class="noborder" width="100%">
<th width="50%">Phone: 855-359-9999
<th width="50%">Fax: 888-965-1964
<tr width="100%">
</table>
<p>
<table class="noborder" width="100%">
<tr width="100%">
<td width="15%">___ Outpatient
<td width="15%">___ Office
<td width="15%">___ Inpatient
<td width="15%">___ DME
<td width="40%">___ Ambulatory Surgery Center
</table>
<p>
<table class="border" width="100%" cellspacing="0">
<tr width="100%">
<td width="50%"><b>ICD-10 CM Diagnosis</b>
<td width="50%"><b>Code</b>
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%"><b>Description</b>
<td width="50%"><b>Code</b>
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="50%">
<td width="50%">
<tr width="100%">
<td width="100%" colspan="2"><b>Special circumstances:</b>
<tr width="100%">
<td width="100%" colspan="2">
<tr width="100%">
<td width="100%" colspan="2">
<tr width="100%">
<td width="100%" colspan="2"><b>Clinical Information:</b>
</table>
I guess you forgot to add closing tags to tr and td, like:
<tr>
<td>
some stuff between
</td>
</tr>
I copy pasted your code into the text editor and it does not have closing tags but I don't have a problem as shown on your image. I opened the inspector in the browser and saw that browser put all the closing tags.
Just add closing tags to all trs and tds, and everything should work as intended.

table colspan in emails

I'm trying to get the image to align to the right and the rows with text on the left in my table using colspan. This method usually works when the image is on the left but now I want it on the right it wont work. Please keep in mind this is for outlook email so you cannot use floats, align="right" etc.
heres my code:
<table cellpadding="0" cellspacing="0" width="600" style="width: 100%; max-width: 600px;">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="580" style="border: 1px solid;">
<tr>
<td style="font-size: 10px;">sdfsdfsdfsdfdsdfhhhhhhhhlklkjlkj</td>
<td></td>
</tr>
<tr>
<td>sdfsdf</td>
</tr>
<tr>
<td rowspan="3" ><img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/e3c991a6-22c4-4ee2-a08d-7d23e30f8c29.png" alt="" width="400"></td>
</tr>
</table>
</td>
</tr>
</table>
https://jsfiddle.net/yk3fanoq/1/
You need to put the text and image in two columns (td)
<table cellpadding="0" cellspacing="0" width="600" style="width: 100%; max-width: 600px;">
<tr>
<td align="center">
<tr>
<td align="left">
sdfsdfsdfsdfdsdfhhhhhhhhlklk
sdfsdf
</td>
<td rowspan="3" align="right">
<img src="https://gallery.mailchimp.com/b083c967cd22e35ab4ce75e7a/images/e3c991a6-22c4-4ee2-a08d-7d23e30f8c29.png" alt="" width="400">
</td>
</tr>
</td>
</tr>
</table>

How to fit 4 columns in 3 column HTML table?

I don't know how to word this question but I'm working on a table and it has 3 columns everywhere but I want to fit 4 cells in into one row so that the width remains the same. How do I do it?
This is what I mean:
-------------
| 1 | 2 | 3 |
-------------
| 1|2 |3|4|
-------------
Is this what you are after? The outer columns are 33% width so it fits the width of the screen. The inner columns of the table is set to 25% width so it fits within the 33% columns. I have given each column a different color border so you can see how it looks.
.column1, .column2, .column3{width:33.3%; font-family: Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";padding:5px 0px;}
.column1{border:1px solid #ff0000;}
.column2{border:1px solid #fff000;}
.column3{border:1px solid #000000;}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="column1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="25%" align="center" valign="middle">1</td>
<td width="25%" align="center" valign="middle">2</td>
<td width="25%" align="center" valign="middle">3</td>
<td width="25%" align="center" valign="middle">4</td>
</tr>
</tbody>
</table></td>
<td class="column2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="25%" align="center" valign="middle">1</td>
<td width="25%" align="center" valign="middle">2</td>
<td width="25%" align="center" valign="middle">3</td>
<td width="25%" align="center" valign="middle">4</td>
</tr>
</tbody>
</table></td>
<td class="column3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="25%" align="center" valign="middle">1</td>
<td width="25%" align="center" valign="middle">2</td>
<td width="25%" align="center" valign="middle">3</td>
<td width="25%" align="center" valign="middle">4</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
Cheers
try this using nested tables
<table cellspacing="0" cellpadding="0" border="1" width="200">
<tr>
<td>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" align="center">1</td>
<td width="33%" align="center">2</td>
<td width="33%" align="center">3</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">3</td>
<td align="center">4</td>
</tr>
</table>
</td>
</tr>
</table>

Table row on top of columns

The text I have on top in the table row is somehow affected by the second column below it..cant seem to have it take up the entire width of the table.
http://jsfiddle.net/PmWBw/2/
Sorry I know I am the only one still working in tables. HTML emails still exist.
<table width="800" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<table>
<tr style="width: 800px;">TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</tr>
</table>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</table>
For starters, your first row consists of a td inside a tr that's inside ANOTHER td. If nothing else, that should probably be addressed.
Also, a bit unrelated to you original question, but it seems a bit redundant to have tables inside of your cells, when I'm not seeing any real benefit or function gained by the added code. You're styling your inner tables with the same things you can be applying to either the td or the image itself. At least in this particular application.
Just a thought.
UPDATED:
<table width="600" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<tr>
<td colspan="2">
<table>
<tr style="width: 600px;">
<td>TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</tr>
</table>
First of all, you can not have the code looking like this:<td><tr><td>asdf</td></tr></td>. It the <tr> needs to be wrapped by <table>.

Table HTML layout

I am trying to setup tables so the result outcomes like this:
Code:
<table width="60%" cellpadding="0" cellspacing="1" id="theBoxer">
<tr style="background: #686868 ;">
<td align="center" valign="top" width="240" height="25" style="border:1px #FFF solid;">About me</td>
</tr>
<tr>
<td align="left" valign="top" width="250" height="112" style="">
Points:<br>
Lalala: <br>
Lalala: <br>
</td>
<td align="left" valign="top" width="250" height="112" style="">
Lalala: <br>
Lalala:
</tr>
</table>
Can't get it to work like how I wanted.
The problem I get with my code is that "About me" only covers for the first cell and not the other.
You need colspan="2" in the <td> of the first row so that it spans two columns.
Semantically, you would like to use <th> (table heading) instead of <td> as well.
See also:
HTML table tutorial
This should do the trick:
<table width="60%" cellpadding="0" cellspacing="1" id="theBoxer">
<tr style="background: #686868 ;">
<td align="center" valign="top" colspan="2" width="240" height="25" style="border:1px #FFF solid;" >
About me
</td>
</tr>
<tr>
<td align="left" valign="top" width="250" height="112" style="">
Points:<br>
Lalala: <br>
Lalala: <br>
</td>
<td align="left" valign="top" width="250" height="112" style="">
Lalala: <br>
Lalala:
</td>
</tr>
</table>
Note the colspan attribute on the first <td> tag - this will ensure that it spans the width of two columns.
Additionally, you might also like to expand your table to contain the thead and tbody elements, providing separation between the different sections of content:
<table width="60%" cellpadding="0" cellspacing="1" id="theBoxer">
<thead>
<tr style="background: #686868 ;">
<th align="center" valign="top" colspan="2" width="240" height="25" style="border:1px #FFF solid;" >
About me
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top" width="250" height="112" style="">
Points:<br>
Lalala: <br>
Lalala: <br>
</td>
<td align="left" valign="top" width="250" height="112" style="">
Lalala: <br>
Lalala:
</td>
</tr>
</tbody>
</table>