Outlook Web App "display :none" not working - html

I am designing a responsive email template and i have a slight problem on Outlook Web app.
I found out that it removes classes so there is no point in using media queries so i try to hide a tr element like this :
<tr style="mso-hide:all;
display:none;
height:0;
width:0px;
max-height:0px;
overflow:hidden;
line-height:0px;
float:left;">
But it still shoes up. Any Ideas?

You can add the
<tr style="visibility: hidden"></tr>
However, this only makes it not visible... It is still there and taking up space

Use such class:
.hide {
display: none !important;
width: 0 !important;
height: 0 !important;
overflow: hidden !important;
}

Blockquote
I'm not entirely sure way you need a hidden table row, but try this:
<tr style="mso-hide:all;
display:none!important;
height:0;
width:0px;
max-height:0px;
overflow:hidden;
line-height:0px;
float:left;">
This may not work as email clients remove some of the CSS, specially lines that will hide code. It will also remove any links to js or external code. So !important will probably be ignored as well.
Lastly trying to hide content is a huge red flag for spam filters, likely whatever you send with this will end up in the spambox.

We use a combination of tables to hide and show different content. Depending on the size of the image you can adjust the height and width of the td.
Styles:
td.inner { display:none; }
table.promo_1_pic_1 { float: none; width:100%; height:95px; }
table.promo_1_pic_1 td { background: #fff url(test.jpg) no-repeat 0px !important; }
table.promo_2_pic_2 { float: none; width:100%; height:95px; }
table.promo_2_pic_2 td { background: #fff url(test.jpg) no-repeat 0px !important; }
table.promo_3_pic_3 { float: none; width:100%; height:109px; }
table.promo_3_pic_3 td { background: #fff url(test.jpg) no-repeat 0px !important; }
table.promo_4_pic_4 { float: none; width:100%; height:109px; }
table.promo_4_pic_4 td { background: #fff url(test.jpg) no-repeat 0px !important; }
HTML:
<td class="desktop-table" bgcolor="#ffffff" style="padding:20px; background-color:#ffffff; font-family: Arial, Helvetica, sans-serif;">
<!-- promo 1 content -->
<table class="promo_1_pic_1"><tr><td></td></tr></table>
<table class="promo_2_pic_2"><tr><td></td></tr></table>
<table class="promotion">
<tr>
<td class="inner"><img src="test.jpg" alt=""/>
</td>
<td class="inner"><img src="test.jpg" alt=""/>
</td>
</tr>
</table>
</td>
<td class="desktop-table" bgcolor="#ffffff" style="padding:0 10px 10px 10px; background-color:#cfe6f6; font-family:Arial, Helvetica, sans-serif;">
<!-- promo 1 content -->
<h3 style="margin:25px 0px 0px 22px;">You might also be interested in:</h3>
<table class="promo_3_pic_3"><tr><td></td></tr></table>
<table class="promo_4_pic_4"><tr><td></td></tr></table>
<table class="promotion">
<tr>
<td class="inner"><img src="test.jpg">
</td>
<td class="inner"><img src="test.jpg">
</td>
</tr>
</table>
</td>

I had the same problem all day yesterday, I found this question here and seems no correct answer. Then I searched in Litmus community forum. And fortunately saw a comment saying:
Also note with mso-hide:all, that if you are trying to hide content within the table cell that includes nested tables, you must apply this property to any and all nested tables within as well.
So I added mso-hide:all to all child tables, and it worked!

Wrap whatever you need to hide in a div.
div {
width: 0;
height: 0;
overflow: hidden;
}

To keep this question up to date, OWA does accept classes now, and can be targeted by adding [owa] to the start of the class list in css.
[owa] .hide,
.hide {
display: none!important;
mso-hide: all;
width: 0;
min-width: 0;
max-width: 0;
height:0;
min-height: 0;
max-height: 0;
overflow: hidden;
font-size: 0px;
line-height: 0px;
}
With this adding .hide to the element you want to hide, will hide it in all popular email clients, if you want to hide from just outlook (excl OWA), then I'd suggest using conditional code. The following table will be hidden in all email clients. Although it will appear when the email is forwarded from certain email clients.
<!--[if !mso]><!-- -->
<table class="hide">
Hide me
</table>
<!--<![endif]-->

Related

Table CSS Padding, Cellspacing, etc

My two custom social buttons. I put them inside a table and set them to in-line block but there's a big space in between both of them! How do I close this gap? I've set the table to a class name of "share." I want to edit through the style-sheet because I don't want to go through every single page and edit its code.
<table class="share">
<tr style="background-color: white;">
<td style="border: none;">
<span style="padding:10px; font-size:15px; text-align: center; background-color:#3B5998; font-weight:bold; font-family: Verdana; color:white; border-radius:10px;">Share on Facebook</span></span></span></p>
</td>
<td style="border: none;">
<span style="padding:10px; font-size:15px; text-align: center; background-color:#55acee; font-weight:bold; font-family: Verdana; color:white; border-radius:10px;">Tweet</span></span></span></p>
</td>
</tr>
</table>
Ok from what i see you are going to have a hard time just doing css, as you have styles within your Html tags already.
CSS: this will make them but up together. Fiddle
table {
border-spacing: 0px;
border-collapse: separate;
}
td {
padding: 0px;
}
The simple solution in your case is to change the table style to display:block; and it should get the td's closer.
try this
.share {
width: auto;
margin: 0;
margin-left: auto;
margin-right: auto;
}

Remove spacing/padding between <TD> with images in them, in OUTLOOK 2007

I'm going absolutely crazy. I have a table, which I've simplified down to two adjacent cells with one image each (the images are part of a larger picture, so there can be NO spacing between them). I'm getting some spacing or padding between the table cells, just on the left and right, not the top or bottom. I've tried everything I can find on forums, both inline html as well as inline CSS styling, including:
cellpadding="0"
cellspacing="0"
border="0"
align="left"
display: block;
display: inline-block;
display: inline-table;
border-collapse: collapse;
border:none;
mso-table-lspace:0;
mso-table-rspace:0;
width:403px!important;
padding-left: 0px;
padding-right: 0px;
padding: 0 0 0 0;
margin: 0 0 0 0;
margin-left: 0px;
margin-right: 0px;
No combination of any of these attributes seem to work. Here is my code if you want to take a look (remember, this is a reduced version). It works perfectly fine in my browser, but when I paste it into Outlook I get spacing before, between and after each cell. I have created a magenta background so I can see the spacing clearly.
<table align="left" border="0" cellpadding="0" cellspacing="0" style="
border:none;
border-collapse:collapse;
background-color:magenta;
font-family:Verdana, Geneva, sans-serif;
font-size:12px;
line-height:15px;
color:#4A4A4A;
width:403px!important;
mso-table-lspace:0;
mso-table-rspace:0;
">
<tr>
<td width="211">
<img src="http://s3.amazonaws.com/cms_assets/accounts/3ceae742-b87e-4bdc-a6b3-2bcfc1c5c2d7/site-30100/cms-assets/images/457997.seal-bar-gold.png" width="211"/>
</td>
<td width="192">
<img src="http://s3.amazonaws.com/cms_assets/accounts/3ceae742-b87e-4bdc-a6b3-2bcfc1c5c2d7/site-30100/cms-assets/images/569397.seal-bar-silver.png" width="192"/>
</td>
</tr>
</table>
<img> it is inline tag, by default, therefore we have space under it. You can set font-size: 0px; for parent to prevent empty space, or set display: block; to <img> (my choice).
My solution and article about this behaviour

IE 10 print appears to be scaled down

I have web application performing report printing.
my code look like this & it works properly.
HTML
<table>
<thead>
<tr>
<th>
Header part
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div id="reportView">
<div class="head centerPosition noPrint">
Report header
</div>
<div class="content" style="margin: 0px;">
<div id="report" style="margin-top: 10px;">
report content
</div>
</div>
<div class="foot noPrint">
Report footer
</div>
</div>
</td>
</tr>
</tbody>
</table>
CSS
<style media="print">
body
{
background-color:#FFFFFF;
margin: 0px; /* this affects the margin on the content before sending to printer */
width: 100%;
}
#site_header, #site_footer, .noPrint
{
visibility: hidden;
display: none;
height: 0px !important;
overflow: hidden !important;
}
#report .content
{
width: 100%; margin: 0px; float: none;
background: transparent;
}
#report {
background-color: white;
width: 100%;
}
</style>
After I print any report, the report is scale down on paper.
If anyone have an idea how to fix this please help me. I have try to search on google but none of the suggestion are work.
Thanks in Advance...
My guess (because I can't test right now) is that you also need to declare width:100% on each of the containers above #report .content (from the HTML you've provided, it looks like #reportView and the table and td that contains it all, but there may be more). Otherwise it will collapse to it's content width, which is the default behavior of a table cell.

Do not resize Table cell

I have large URL(without spaces) in one of my Table(html table element) cell which resize table. I do not want to resize table, what property should I set to break URL into new line?
HTML
<table class="ui-grid" cellspacing="0" rules="all" border="1" id="MainContent_gvStatistic" style="border-collapse:collapse;">
<caption>Statistic (Last 50 conversions)</caption>
<tbody><tr>
<th scope="col">Date</th>
<th scope="col">Result</th>
<th scope="col">Api</th>
<th scope="col">IP</th>
<th scope="col">Source</th>
</tr><tr>
<td style="width:200px;">12/16/2011 3:23:59 PM</td>
<td align="center" style="width:50px;">True</td>
<td align="center" style="width:100px;">Web2Pdf</td>
<td align="center" style="width:100px;">::1</td>
<td style="width:200px;">http://a1.quickcatchlabs.com/phototemplates/football_blimp_1.html?i_url=http%3A//lh3.ggpht.com/yf5lVBB_WNBvBHT1HoIzY1SG0-PY5zRCobP3vBacuSk9N346F7CeAIRSFOltR6ZC1-yf-MNKAcAd7bAZ_A%3Ds612-c&i_name=Patriots%20%20vs%20Redskins&i_venue_name=Gillette%20Stadium%20&i_venue_address=Foxborough%20%2C%20MA&d_Score_0=34&d_Score_1=27&d_Period_0=Final&p_name_0=Patriots%20&p_name_1=Redskins</td>
</tr>
</tbody></table>
CSS
.ui-grid { width: 100%; margin: 5px 0 10px 0; border: solid 1px #eeeeee; border-collapse: collapse; }
.ui-grid td { padding: 2px; border: solid 1px #eeeeee; }
.ui-grid td b { font-weight: bold; }
.ui-grid th { padding: 4px 2px; color: #fff; background: #000000; border-left: solid 1px #eeeeee; text-align: center; }
.ui-grid .alt { background: #fcfcfc; }
.ui-grid .pgr { background: #424242; }
.ui-grid .pgr table { margin: 5px 0; }
.ui-grid .pgr td { border-width: 0; padding: 0 6px; border-left: solid 1px #666; font-weight: bold; color: #fff; line-height: 12px; }
.ui-grid .pgr a { color: #666; text-decoration: none; }
.ui-grid .pgr a:hover { color: #000; text-decoration: none; }
Add the following to your css
table-layout:fixed
word-wrap:break-word
The following site has a good walk through of this
http://www.456bereastreet.com/archive/200704/how_to_prevent_html_tables_from_becoming_too_wide/
i modified your code a little and this is what works for me hopefully it will help you
<html>
<div id="wrap">
<div id="content-primary">
<table class="table" cellspacing="0" rules="all" border="1" id="MainContent_gvStatistic" style="border-collapse:collapse;">
<caption>
Statistic (Last 50 conversions)
</caption><tbody>
<tr>
<th scope="col">Date</th><th scope="col">Result</th><th scope="col">Api</th><th scope="col">IP</th><th scope="col">Source</th>
</tr>
<tr>
<td style="width:100px">12/16/2011 3:23:59 PM</td><td align="center" style="width:50px;">True</td>
<td style="width:100px">Web2Pdf</td>
<td style="width:100px">::1</td>
<td style="width:100px">http://a1.quickcatchlabs.com/phototemplates/football_blimp_1.htmli_url=ht%3A//lh3.ggpht.com/yf5lVBB_WNBvBHT1HoIzY1SG0-PY5zRCobP3vBacuSk9N346F7CeAIRSFOltR6ZC1-yf-MNKAcAd7bAZ_A%3Ds612-%20%2C%20MA&d_Score_0=34&d_Score_1=27&d_Period_0=Final&p_name_0=Patriots%20&p_name_1=Redskins</td>
</tr>
</tbody></table>
</div>
</div>
</html>
<style type="text/css" media="screen,print,projection">
#import '/css/lab.css';
#wrap {
width:60em;
margin:2em auto;
}
#content-primary {
float:left;
width:60%;
}
#content-secondary {
float:right;
width:36%;
}
table {
width:100%;
border:1px solid #f00;
word-wrap:break-word;
}
th,
td {
vertical-align:top;
text-align:left;
}
</style>
The most practical approach is to add the tag <wbr> after each acceptable break point, such as “/”, “?”, and “&” (maybe also “=”). This tag has been supported by browsers since the early days; it is not included in any HTML specification (though it is proposed to be standardized in HTML5), but it works practically always and has no know drawbacks.
Since this is about a URL in text, the breaks should appear at natural points of division, not arbitrarily. Various style guides (like The Chicago Manual of Style) have their own recommendations, but the simple break point rules mentioned above should be acceptable on all accounts and normally suffice.
There’s some more info on my page on word division in HTML and related matters.
You can try several things:
add the CSS3 property word-wrap: break-word;
You can put a div inside your table cells. Nothing within that div will stretch out the table cell.
max-width css property
Surround the URL in a containing div inside the td. Apply word-wrap:break-word; width:200px to the div container. The div container is for the benefit of IE. In Chrome, for instance, the styles can be applied directly to the td.
word-wrap is non-standard, however, it has excellent browser support, including IE6+.
Here is an example fiddle.

Make link in table cell fill the entire row height

I have a table of data and each cell is a link. I want to allow the user to click anywhere in the table cell and have them follow the link. Sometimes the table cells are more than one line but not always. I use td a {display: block} to get the link to cover most of the cell. When there is one cell in a row that is two lines and the others are only one line the one liners don't fill the entire vertical space of the table row. Here is the sample HTML and you can see it in action here http://www.jsfiddle.net/RXHuE/:
<head>
<style type="text/css">
td {width: 200px}
td a {display: block; height:100%; width:100%;}
td a:hover {background-color: yellow;}
</style>
<title></title>
</head>
<body>
<table>
<tbody>
<tr>
<td>
<a href="http://www.google.com/">Cell 1<br>
second line</a>
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
<td>
Cell 4
</td>
</tr>
</tbody>
</table>
</body>
Set an arbitrarily large negative margin and equal padding on the block element and overflow hidden on the parent.
td {
overflow: hidden;
}
td a {
display: block;
margin: -10em;
padding: 10em;
}
http://jsfiddle.net/RXHuE/213/
You need a small change in your CSS. Making td height:100%; works for IE 8 and FF 3.6, but it doesn't work for Chrome.
td {
width: 200px;
border: solid 1px green;
height: 100%
}
td a {
display: block;
height:100%;
width:100%;
}
But making height to 50px works for Chrome in addition to IE and FF
td {
width: 200px;
border: solid 1px green;
height: 50px
}
td a {
display: block;
height:100%;
width:100%;
}
Edit:
You have given the solution yourself in another post here; which is to use display: inline-block;.
This works when combined with my solution for Chrome, FF3.6, IE8
td {
width: 200px;
border: solid 1px green;
height: 100%}
td a {
display: inline-block;
height:100%;
width:100%;
}
Update
The following code is working for me in IE8, FF3.6 and chrome.
CSS
td {
width: 200px;
border: solid 1px green;
height: 100%;
}
td a {
display: inline-block;
height:100%;
width:100%;
}
td a:hover {
background-color: yellow;
}
HTML
<table>
<tbody>
<tr>
<td>
<a href="http://www.google.com/">Cell 1<br>
second line</a>
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
<td>
Cell 4
</td>
</tr>
</tbody>
</table>
The example lays here
Little late to the party, but there's a nice solution I just discovered.
You can use a combination of relative and absolute positioned elements, along with a pseudo element to get the effect you're looking for. No extra markup needed!
Change the table cell (<td>), to be position: relative;, and create a ::before or ::after pseudo element on the <a> tag, and set it to position: absolute;, and also use top: 0; left: 0; right: 0; bottom: 0;.
Because the pseudo element is attached to the anchor tag, and you're telling it to take up the entire table cell, it will force the anchor tag to be at least that size, whilst not affecting the actual content of the anchor tag itself (thereby retaining its vertically centered alignment).
For example
table {
border-collapse: collapse;
table-layout: fixed;
}
td {
position: relative;
width: 200px;
padding: 0.5em 1em;
border: 2px solid red;
background-color: lime;
}
td a {
/* FONT STYLES HERE */
text-decoration: none;
}
td a::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 0;
}
<table>
<tbody>
<tr>
<td>
<a href="http://www.google.com/">Cell 1<br>
second line</a>
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
<td>
Cell 4
</td>
</tr>
<tr>
<td>
Cell 5
</td>
<td>
<a href="http://www.google.com/">Cell 6<br>
second line</a>
</td>
</tr>
</tbody>
</table>
Hope this helps!
Following hack works [Tested on Chrome / Firefox / Safari]
Have the same padding for td and anchor elements. And for anchor also have margin which is equal to -ve of padding value.
HTML
<table>
<tr>
<td><a>Hello</a></td>
</tr>
</table>
CSS:
td {
background-color: yellow;
padding: 10px;
}
a {
cursor:pointer;
display:block;
padding: 10px;
margin: -10px;
}
Working Fiddle :http://jsfiddle.net/JasYz/
Try display: block:
td a {display: block; height:100%;}
[EDIT] WTF ... I can confirm this doesn't work in FF 4 and Chrome. This works:
td a {display: block; height: 2.5em; border: 1px solid red;}
That suggests that height:100%; isn't defined in a table cell. Maybe this is because the cell gets its size from the content (so the content can't say "tell me your size" because that would lead to a loop). It doesn't even work if you set a height for the cells like so:
td {width: 200px; height: 3em; padding: 0px}
Again the code above will fail. So my suggestion is to use a defined height for the links (you can omit the width; that is 100% by default for block elements).
[EDIT2] I've clicked through a hundred examples at http://www.cssplay.co.uk/menus/ but none of them mix single line and multi-line cells. Seems like you hit a blind spot.
I will post the same answer here, as I did on my own question.
Inspired by Jannis M's answer, I did the following:
$(document).ready(function(){
$('table tr').each(function(){
var $row = $(this);
var height = $row.height();
$row.find('a').css('height', height).append(' ');
});
});
I added a since empty links (not containing text nodes) can not be styled(?).
See my updated fiddle.
Only problem here is that using display: block forces the browser to ignore the vertical align: center...
oops.
I jury rigged it to look right for one cell with height:60 and a font that occupied 20 pixels by adding a br... Then I realized that I had some items with 2-line text. Dang.
I ended up using the javascript. The javascript doesn't give the nice mousey pointy clicker thing, but the line of text does, so it will actually trigger a visual response, just not where I want it to... Then the Javascript will catch all the clicks that 'miss' the actual href.
Maybe not the most elegant solution, but it works well enough for now.
Now if I could only figure out how to do this the right way....
Any ideas on how to add the mouse icon change to a hand for the area covered by the onclick? Right now, the click to page works, but the icon only changes when it hits the href which only affects the text.
Why don't you just get rid of the <a> altogheter and add an onClick to the <td> directly?
<head>
<style type="text/css">
td {
text-align:center;
}
td:hover {
cursor:pointer;
color:#F00;
}
</style>
<title></title>
</head>
<body>
<table>
<tbody>
<tr>
<td onclick="location.href='http://www.google.com/';">Cell 1<br />second line</td>
<td onclick="location.href='http://www.google.com/';">Cell 2</a></td>
<td onclick="location.href='http://www.google.com/';">Cell 3</td>
<td onclick="location.href='www.google.com';">Cell 4</td>
</tr>
</tbody>
</table>
This way you cut out the middle man.
PS: i know this was asked and answered many years ago, but none of the answers above solved the problem in my case. Hope this helps someone.
For me the only solution is to replace <table> <tr> with <div>s and style them using display:table and display:table-row accordingly.
Then you can replace <td> with just <a> and style it with display:table-cell.
Work perfectly even on varying heights of <td> contents.
so original html without anchors:
<table>
<tr>
<td>content1<br>another_line</td>
<td>content2</td>
</tr>
</table>
now becomes:
a:hover
{
background-color:#ccc;
}
<div style="display:table; width:100%">
<div style="display:table-row">
content1<br>another_line
content2
</div>
</div>
I have used this solution: works better then the rest in my case.
CSS:
.blocktd {width: 100%; height: 100%; padding: 0px; overflow: hidden}
a.blocktd {margin: 0em; padding: 50px 20px 50px 20px; display: block;}
a.blocktd:hover {border: 4px solid #70AEE8; border-radius: 10px; padding: 46px 16px 46px 16px; transition: 0.2s;}
And in HTML: ...