Table design with one pixel width & height - html

I want to design a table with height and width of 1px.
Is this possible, cause I couldn't do that?
Any advice would be appreciated.
EDIT:
I did it, actually I needed to use !important in my css style, but the space between cells are present. How should I remove them?
<table width="100%" style="height:1px !important;">
<tr style="height:1px !important;">
<td style="background-color:red; width:1px;">
</td>
<td style="background-color:blue; width:1px;">
</td>
<td style="background-color:orange;">
</td>
<td style="background-color:red; width:1px;">
</td>
</tr>
</table>

This is an HTML-only answer that works across browsers and settings:
<body>
<table cellpadding=0 cellspacing=0>
<tr><td width=1 height=1></td></tr>
</table>
To set the color of the pixel, you can use the bgcolor attribute on the td element.
I can’t imagine what your purpose is, but this answers the question that was asked.

Yes you can just take a look at this Fiddle:
http://jsfiddle.net/yaAJ7/
It is better practice to use DIV's though rather than tables

Related

HTML: cell padding and spacing in selected row or column

i just started learning in HTML.
I'm having a problem in cell padding and spacing...
the one that i created have a cell padding and spacing on all row... is it possible to have a cell spacing and padding in the 1st row but not in the 2nd row?
`
</td>
<tr>
<td width="250" height="500">
</td>
<td width="750">
</td>
</tr>
<tr>
<td colspan="2" height="75">
</td>
</tr>
`
You can simply add padding to each TD not TR
But spacing between cells only for the whole TABLE
The Attribute padding is the response about cell padding
<table border="1" style="border-spacing:2px;">
<tr>
<td width="250" height="500" style="padding:5px;">One</td>
<td width="750" style="padding:5px;">Two</td>
</tr>
<tr>
<td colspan="2" height="75">Three</td>
</tr>
</table>
I would suggest to wrap the content you want to edit in a and add css properties like for example:
Take a look at this div and style combination, it gets kinda useful sometimes. You can make the particular elements special even when they are in a table with constant style.
You can even add this style attribute to the / tags themselves. Maybe what you're looking for.

Html ColSpan/RowSpan not working as expected

I am facing a strange bug that is happening on both IE and Chrome. I have and application that loads a matrix of info but for some reason in a specific case things dont show correctly. By configuration i am able to change the way the info is being displayed and for that i use the rowspan and colspan.
I am not using any Javascript, just html. This image show what is happening:
Sorry still cant post image but here is the fiddle
http://jsfiddle.net/gondias/22o07mbt/
<table cellspacing="6" cellpadding="0" style="width:558px; background-color:red">
<tr>
<td colspan="3" rowspan="2">
<div class="tile_3x2"></div>
</td>
<td colspan="1" rowspan="2">
<div class="tile_1x2"></div>
</td>
</tr>
<tr></tr>
<tr>
<td colspan="2" rowspan="2">
<div class="tile_2x2"></div>
</td>
<td colspan="2" rowspan="2">
<div class="tile_2x2"></div>
</td>
</tr>
<tr></tr>
<tr>
<td colspan="4" rowspan="1">
<div class="tile_4x1"></div>
</td>
</tr>
<tr>
<td colspan="4" rowspan="1">
<div class="tile_4x1"></div>
</td>
</tr>
</table>
For some reason the 1st cell in the second row gets extended pushing the following one.
Let me know of any questions you may have.
I think the usage of the rowspan/colspan is correct. Does anyone know what is happening here.
Thanks for the help, i'm really struggling here.
Do you really need to use tables here? Is it used for an email newsletter?
You can use divs with display: inline-block; to get the desired result without a table.
If you really need to take this way (not recommended), this is your solution:
http://jsfiddle.net/rcdmk/22o07mbt/1/
td {
width: 132px;
}
If you place a border on the TD tags you will see what's happening there. The cells (columns) doesn't have specific widths so the browser have to guess based on the content and this is not a consistent behavior between browsers. You will have to just give a width to the cells.

Colspan is disturbing table layout

Please see below html:
<table style="width: 700px;table-layout: fixed ; margin-top: 30px;" cellpadding="0" cellspacing="0">
<tr class="tableHeader">
<td width="220px">Event Name</td>
<td width="120px">City</td>
<td width="77px">Date</td>
<td width="110px">Price</td>
<td width="80px">Status</td>
<td width="60px">Select</td>
</tr>
</table>
<div style="overflow: auto;height: 360px; width: 730px;">
<table style='width: 700px;table-layout: fixed;' cellpadding='0' cellspacing='0'>
<tr >
<td colspan='6' >adnanpo </td>
</tr>
<tr >
<td width='220px' >adnanpo </td>
<td width='120px' > </td>
<td width='77px' >04/20/2012 </td>
<td width='110px' >USD $30.00 </td>
<td width='80px' >Paid </td>
<td width='60px' >
<input class='orgOkButton' type='button' id='btnOpenOrder' name='btnOpenOrder' onclick='return openOrderWindow('/RealResource/submitorder.aspx?OId=35731&EvtId=771')</td>
</tr>
</table>
</div>
Below part is casuing the issue:
<tr >
<td colspan='6' >adnanpo </td>
</tr>
Please sse the image, the column width is disturbed!! Please help me to fix it!
The obvious solution is to remove the tr element that causes the problem. It does not seem to have a function here. If you just want some spacer there, put a div element between the two tables.
The problem arises because table-layout: fixed tells the browser to decide on column widths according to the first row, if widths have not been set in certain other ways. Here the first row has just one cell that spans all columns, and then the defined behavior is to divide the width evenly between the columns.
Alternatively, set the column widths explicitly, e.g. using
<col width=220>
<col width=120>
etc. right after each <table> tag. But make sure that the sums of the widths add up to the number you set as the total width of the table (they currently don’t). When col elements are used that way to set all column widths, browsers will use those exact widths without questioning (which may cause problems, but I presume you have considered them).
Remove 'table-layout' property in your second table and it will work fine. And close you input element (onclick="return openOrderWindow('/RealResource/submitorder.aspx?OId=35731&EvtId=771')"/>)
If I understand correctly, you are worried to the fact that your columns are not aligning to the top.
Let me first suggest that you use the below CSS:
table { empty-cells: show; }
This will allow the empty cell you have to fill in the space. (otherwise you can just put an in it's blank space).
Also, I suggest you use one continuous table if you can.
Close your input-tag - the > is missing. If the problem is still there we can look further.
Yes this will be the case by using colspan in the "first row" of a table. To get around this you could do something like this (again just for the first row - you can use colspan fine further down):
<tr>
<td width="220px"><div style="position:absolute;width:220px;">adnanpo</div></td>
<td width="120px"></td>
<td width="77px"></td>
<td width="110px"></td>
<td width="80px"></td>
<td width="60px"></td>
</tr>

Email template boilerplate - unable to set row height

I'm using this boilerplate: http://htmlemailboilerplate.com/
I want a table row to be 6px of height and one row to be 1px of height. No matter what I try the table rows wont go less than a height of 15px. Coincidently 15px is the font-size.
Code:
...
<tr>
<td height="6" style="height: 6px;"> </td>
</tr>
<tr>
<td height="1" style="height: 1px;"><img src="images/bar.gif" width="220" height="1" /></td>
</tr>
...
Any way I can get this table rows to be the height I want?
Did you try using CSS to set line-height:1px on your td?
I dont know if they have changed the rules for Outlook 2013 recently, but I found that setting line height and font size on the TD didnt work. I even tried setting it on the TR, that didnt work either.
I put a & nbsp; in the cell and set its font size to 0px as well as putting line height and font size on the TD just to make doubly sure. That seems to have worked for me.
The example below has a 2px green cell - tested in litmus and "real" 2013. Hope this helps!
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" bgcolor="#0000CC"></td>
</tr>
<tr>
<td height="2" bgcolor="#00FF00" style="line-height:0px; font-size:0px;"><font style="font-size:0px; -webkit-text-size-adjust: none;"> </font></td>
</tr>
<tr>
<td height="20" bgcolor="#0000CC"></td>
</tr>
</table>
I needed to add
table td { mso-line-height-rule: exactly; }
to make it work in Outlook 2013.
Table cells will expand to hold the content you put in them, no matter what height you set them to be.
The non-breaking space will be the height of a line. You need to wrap it like this:
<span style="line-height:1px;font-size:1px;">&nbsp</span>
Similarly, the cell with the image will be at least as tall as bar.gif
I use line-height and font-size (if smaller than the current) with a (space) -
<table width="600" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="line-height:5px; font-size:5px;"> </td>
</tr>
</table>
Or if inline -
<span style="line-height:5px; font-size:5px;"><br /><br /></span>

How to make this code vertical-align to the bottom

Got this simple piece of html code and I want to make the TEST (third <td> component) align to the bottom of the row but it stays up no matter what I try.
I know there are thousands of questions of this sort and I read 3-4 articles but non of the stuff I tried works.
<table border="0">
<tr>
<td width="144" height="125"><img src="images/logo.png" alt="CommuniTake" width="143"
height="123"></td>
<td width="775">
<h1><h:outputText value="#{msg.General_Configuration_Title}" /></h1>
</td>
<td style="float:right;vertical-align:text-bottom">
TEST
</td>
</tr>
</table>
Thanks!
<td valign="bottom">
should work
Just remove the float and make it vertical-align: bottom and it'll fall to the abyss!
How about:
<table border="0">
<tr>
<td width="144" height="125"><img src="images/logo.png" alt="CommuniTake" width="143"
height="123"></td>
<td width="775">
<h1><h:outputText value="#{msg.General_Configuration_Title}" /></h1>
</td>
<td valign="bottom">
TEST
</td>
</tr>
</table>
From W3Schools:
text-bottom The bottom of the element is aligned with the bottom of the parent element's font
Might be that this td does not have a parent element, which has font to align to. Using simple 'bottom', as suggested by others, would align to lowest element on the same line.