Is it possible to somehow place a whole HTML table in a href link?
Something like: (does not work in IE)
<td class="order_confirm">
<a href="ssss">
<div>
<table width="100%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td><img src="design/img/icon_ok.png" width="22" height="22" alt="objednat" /></td>
<td width="0" class="order_confirm_order">OBJEDNAT</td>
<td width="100%" class="order_confirm_order_desc">Záväzne si objednávam uvedený tovar a súhlasím s platobnými,<br />
dodacími a obchodnými podmienkami prevádzkovateľa.</td>
</tr>
</table>
</div>
</a>
</td>
I am aware of the fact that this is not the best practice, however, I don't really see a workaround for this using a non-table layout... So a solution with a non-table layout would also be acceptable for me.
It isn't correct to place div's or table's in a. (See selfhtml for more information).
What you can do is something like this:
<div onclick="document.location.href = 'new location';">....</div>
In HTML 5 you can put block elements inside an inline element, so there it would work.
For any browser that doesn't support HTML 5, or if you don't have an HTML 5 doctype in the page, the markup will break, and the div and the table will end up outside the link.
If you want your whole table as a link you can simulate it css and javascript.
This example uses jQuery:
<style>
#big-link {
cursor: pointer;
}
</style>
<script>
$(function() {
$("#big-link").click(function() {
window.location.href = "ssss";
});
});
</script>
<div id="big-link">
<table>
...
</table>
</div>
Using html4 event attributes you can make the table itself an anchor-tag.
<table
style="cursor:pointer"
onMouseover="window.status='http://www.stackoverflow.com/'"
onMouseout="window.status=''"
onMouseup="window.location='http://www.stackoverflow.com/'"
width="500" height="500">
Related
I wanted to have a full-width call-to-action banner on my client's website. The template that my client has does not support CSS, so I'm making use of like old school HTML to build pages.
I have a background image for the img src and I want to overlay the text in it. I'm in need of a code that is working since I'm really not well-versed.
I searched up for solutions in adding overlay text to a background image, but most of the answers contain CSS. Here's a code that I tried.
<table>
<tr>
<td></td>
<td rowspan=4><img src="/uploads/image12345jpg"></td>
</tr>
<tr>
<center><td colspan=4>This is the overlay text</td></center>
</tr>
</table>
</center>
I'd appreciate your help and answers.
The support says that I have to individually add it in the HTML code... not sure where it goes.
I think you might be looking for something like this: https://jsfiddle.net/DIRTY_SMITH/vz04m3ph/2/
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR>
<TD width="221" height="300" background="https://placeimg.com/640/480/any" valign="bottom">
<FONT size="+1" COLOR="red">This is the overlay text</FONT>
</TD>
</TR>
</TABLE>
EDIT:
This question is asking how to use inline styles, I think:
(I've also put some inline javascript on a click function because you mentioned your scripts wernt working either)
https://jsfiddle.net/DIRTY_SMITH/vz04m3ph/28/
<td style="position:relative;">
<img src="https://placeimg.com/640/480/any" style="position:absolute;z-index:1;" width="600px" height="150px" />
<div style="z-index:2;position:relative;color:red;font-weight:bold; font-size: 40px; top: 40px; left: 100px;" onClick="(function(){
alert('See You can click me');
return false;
});">
<a href="#" onClick="(function(){ alert('See You can click me'); return false; })();return false;">
your text goes here click here</a>
</div>
</td>
This worked for me. Thank you for the help! Appreciate it.
<div class="container" style="position:relative;text-align:center;color:white;" >
<img class="img-responsive" src="https://placeimg.com/640/480/any" alt="#" style="width:1880px;height:250px;" >
<div class="centered" style="position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);" >Example Text</div>
</div>
I need to find the selected DIV using a 'Employment' text for h3 tag.
I can find it using the following XPATH:
.//div[table[tbody[tr[td[h3[text() = 'Employment']]]]]]/following-sibling::div[#class = 'pbBody']
But this is too big and ugly, what is the good way? something like:
parent::div[h3]following-sibling::div, so without this [table[tbody[tr[td[
HTML text:
<div class="listRelatedObject customnotabBlock">
<div class="bPageBlock brandSecondaryBrd secondaryPalette">
<div class="pbHeader">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="pbTitle">
<img class="minWidth" width="12" height="1" title="" style="margin-right: 0.25em;" alt="" src="/img/s.gif"/>
<img class="relatedListIcon" title="Custom" alt="Custom" src="/img/s.gif"/>
<h3 id="a1H9E000000528F_00N2400000IF18T_title">Employment</h3>
</td>
<td class="pbButton">
<td class="pbHelp">
</tr>
</tbody>
</table>
</div>
<div id="DIV_THAT_I_NEED_TO_FIND" class="pbBody">
<div class="pbFooter secondaryPalette">
</div>
</div>
If you want shorter version you can try
//h3[.="Employment"]/following::div[#class="pbBody"]
The most simple locator:
//div[#class="pbBody"][.//h3[text()='Employment']
but better to use "contains", as usually classes could be added to element
//div[contains(#class, "pbBody")][.//h3[text()='Employment']
And last one is similar to #Andersson 's, but corrected (as you need not following element, but ancestor):
//h3[.="Employment"]/ancestor::div[#class="pbBody"]
I am using a base tag with an iframe tag and I would like to know how I can restrict certain links that open in the iframe.
e.g I have a menu panel and when clicked on menu link that desired page is displayed in the iframe.
<div class="start">
<h1 class="start">Geek Box <img src="box_icon.png" alt="Box width=" 40" height="40"></h1>
<hr />
</div>
<div class="table">
<table class="table" border="1" align="center">
<tr>
<td>
Home
</td>
<td>Tech Charts</td>
<td>Videos</td>
<td>About Me</td>
</tr>
</table>
</div>
<hr />
<br />
<div>
<table border="1" width=100% height="500px" style="text-align:center">
<tr>
<td width="25%">Smart Phones</td>
<td width="25%">Laptops</td>
<td width="25%">Dektops</td>
<td width="25%">Tablets</td>
</tr>
<base target='display' />
<tr><td colspan="4"><iframe name="display" frameborder=0 width="100%" height="500px" /> </td></tr>
</table>
</div>
If I understand correctly, you would like some of the pages to open in the iframe, and others in either the same window or another one (or whatever other way), ie. not in the iftame.
This won't work with the base tag using your example because...
The HTML <base> element specifies the base URL to use for all relative URLs contained within a document.
...and also
There can be only one <base> element in a document.
...so using another base tag would not make it work the way you want it.
Instead you'll have to get rid of the base tag, and add the target attribute to each of those links that you want to appear in the iframe.
So assuming you would like to open only the "sub-menus" (so they seem at least, ie. phone, laptop... etc) in the iframe, this is what I suggest you change your code to:
<div>
<table border="1" width=100% height="500px" style="text-align:center">
<tr>
<td width="25%"><a href="phone.html" target='display'>Smart Phones</a></td>
<td width="25%"><a href="laptop.html" target='display'>Laptops</a></td>
<td width="25%"><a href="Desktop.html" target='display'>Dektops</a></td>
<td width="25%"><a href="Tablets.html" target='display'>Tablets</a></td>
</tr>
<!-- Notice I have removed the 'base' tag! -->
<tr><td colspan="4"><iframe name="display" frameborder=0 width="100%" height="500px" /> </td></tr>
</table>
</div>
...and you can leave the rest of your code intact.
Quoted source: <base - HTML | MDN
I'm working on a site targeting older feature phone type mobiles that have limited css and html support. I have a table with a single row and two cells, that each contain a link. Ideally i would like both to be clickable. I tried a div solution but on some of the phone browsers I tested the text would dissapear, I assume because this is not entirely semantical.
Any sugggestions on how to accomplish this without using a div?
here is my html
<div><table style="width:100%;"><tbody><tr>
<td class="leftTd"><Left</div></td>
<td class="rightTd"><a href="link2>Right</a></td>
</tr></tbody></table></div>
The markup of the HTML you gave isn't valid. Here it is as valid markup
<table style="width:100%;">
<tbody>
<tr>
<td class="leftTd">Left</td>
<td class="rightTd">Right</td>
</tr>
</tbody>
</table>
then if you make sure the a element are set to display: block; e.g
td a {
display: block;
}
DEMO
td a {
display:block;
width:100%;
height:100%;
}
Also fixed your HTML markup from errors:
<div>
<table style="width:100%;">
<tr>
<td class="leftTd">Left</td>
<td class="rightTd">Right</td>
</tr>
</table>
</div>
In the first link, you have a stray <.
In the second, you didn't close the quotes after href.
Old phones typically have browsers that won't grok broken HTML syntax very well, so I think this is the reason the links won't render.
I suggest you use an editor that checks HTML syntax, or at least some checker like the W3C validator.
HTML4 event attributes
<table border="0" style="cursor:pointer" onMouseover="window.status='http://www.stackoverflow.com/'" onMouseout="window.status=''" onMouseup="window.location='http://www.stackoverflow.com/'" width="158" height="158" style="background-image: url('http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png')">
<tr>
<td style="display:none;">This entire table is a link with no content</td>
</tr>
</table>
I have a table coded as below;
<table style="table-layout:fixed">
<tr>
<td class="htTd" width="100" style="word-wrap:break-word">someDynamicLongtextsomeLongtextsomeLongtextsomeLongtextsomeLongtextsomeLongtextsomeLongtextsomeLongtext</td>
<td class="htTd" width="100" style="word-wrap:break-word">someLongtextsomeLongtextsomeLongtext</td>
</tr>
<tr>
<td class="htTd" width="100" style="word-wrap:break-word">someContentsomeContentsomeContent</td>
<td class="htTd" width="100" style="word-wrap:break-word">someContent</td>
</tr>
</table>
In CSS, I have
htTd{height:30px}
Now the issue is that since the content is dynamic (coming from JSP), the long text does not wrap correctly in IE. In IE, it kind of displays 2 lines and just hides the rest of the content. It wraps correctly in Firefox.
While the issue can be fixed by just removing the height attribute from the CSS...Unfortunately I cannot do that since my CSS is used in many other files and hence I cannot change the CSS.
How do I fix the issue by adding any other CSS attribute in the CSS ?
I believe that the attribute should be break-word. This
<td class="htTd" width="100" style="word-wrap:break:word">
should be:
<td class="htTd" width="100" style="word-wrap:break-word">
you can for example add an id to the table and write something like this:
#tableId td{height: auto !important;}
or just
#tableId .htTd{height: auto} (i would vote for that one)