How to Overlay Text on Image Using HTML with no CSS? - html

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>

Related

XPATH - Find element where child items h3 text has a specific value

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"]

Converting a HTML table full of images to look decent on mobile

I have a HTML table that's completely composed of eight images. They're puzzle pieces, so they have to be placed specifically and accurately.
This was easy on desktop, I just used absolute positioning to mess around with the pixels and make it work. It looks like trash on mobile though. The pieces are still together, but the puzzle is all the way to the right of the screen and it's too large. I've done a fair bit of Googling, but the only results I found were for tables composed of text, which doesn't work for my situation.
Here's the table, if anyone's interested -
<table width="100%" id="table" border="0" cellpadding="0" cellspacing="5" align="center">
<tr>
<td id="one">
<img src="1.png" class="merge0">
</td>
<td id="two">
<img id="2" src="6.png" class="merge">
</td>
<td>
</td>
</tr>
<tr>
<td id="three">
<img src="4.png" class="row1">
</td>
<td id="four">
<img src="2.png" class="merge1">
</td>
<td id="five">
<img src="7.png" class="merge2">
</td>
</tr>
<tr>
<td id="six">
<img src="8.png" class="row2">
</td>
<td id="seven">
<img src="5.png" class="row3">
</td>
<td id="eight">
<img src="3.png" class="row4">
</td>
</tr>
</table>
I read a bit about jQuery mobile, but I've never really grasped the concept of jQuery, and mobile is a foreign platform to me. I'm hoping to learn though :)
I've also tried those "desktop to mobile" converters, and they all are horrible.
Edit - I think people might suggest that I completely take the table out and use a different method of arranging my images. I'm really not sure how to go about doing this, and I'd prefer it if I could keep my current setup. If it's not possible though, I'd appreciate some pointers on how to do it differently.
Go over the getting started page and then use jQuery-mobile grids:
<div class="ui-grid-a">
<div class="ui-block-a"><img src="1.png" class="merge0"></div>
<div class="ui-block-b"><img id="2" src="6.png" class="merge"></div>
</div>
For the grid with three images just use "ui-grid-b"
Hope this helps
best
M

Table pictures alignment issue

For the first time I am posting here cause if usually I am able to find a solution to my code issues throughout other answers, this time, no matter what I try, it doesn't work.
I am doing a table with two rows with basically pictures on the first row linking some PDF docs with a title below (second row).
The thing is that pictures do not have the same size (that can't be change). I would like them to be align on the bottom of the row, with a small margin before the separation line.
Right now, they are centered (by default I guess) which is not bad but not what I want anyway.
The second issue that I have while they are centered is that the first picture of of the row is always a bit higher than the rest for some reason. Can't figure out why.
Hopefully you can help me with the code written below (I assume that its full of mistakes since several calls doesn't work and could probably be removed).
<table width="780"; bgcolor="#e8e8e8" style="table-layout:fixed" VALIGN="top">
<tr>
<td style="word-wrap: break-word;"; ALIGN="CENTER">
<div align="center";>
<a href="PDF URL" target="_blank">
<img src="URL" alt="ALT">
</a>
</div>
</td>
<td>
<div align="center">
<a href="PDF URL" target="_blank">
<img src="URL" alt="ALT">
</a>
</div>
</td>
<td>
<div align="center">
<a href="PDF URL" target="_blank">
<img src="URL" alt="ALT">
</a>
</div>
</td>
</tr>
<tr>
<td><div align="center"><p style="font-size:11px"><a title="TITLE1" href="URL" target="_blank">TITLE1</p></a>
</div></td>
<td><div align="center"><p style="font-size:11px"><a title="TITLE2" href="URL" target="_blank">TITLE2</p></a>
</div></td>
<td><div align="center"><p style="font-size:11px"><a title="TITLE3" href="URL" target="_blank">TITLE3</p></a>
</div></td>
<td><div align="center"><p style="font-size:11px"><a title="TITLE4" href="URL" target="_blank">TITLE4</p></a>
</div></td>
{/tr}
{/table}
You should first include a .css file call in your header like this:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Then u can create a "mystyle.css" file in order to apply all the styles you want for your table.
Take a look at this page. W3School - CSS
There u have some examples about how to change color, margin, background images and so on.
EDIT:
If you want o apply all the styles in the .html file try looking at this web. http://www.w3schools.com/tags/
There u have all html tags, select the one u want and see the attributes could use.

Html img 1 pixel line underneath

I am not a html programmer but I have to fix an urgent problem. Since this is a private project, I can't post the code here. But here is the obfuscated page source (Note: a href tag is created by Spring Security tag)
<td width="359">
<table style="margin-left:auto; margin-right:8px">
<tbody><tr>
<td>
<img src="/img/Login.gif" alt="Login" height="18" border="0" width="120">
<br>
<br>
<img src="/img/newAct.gif" alt="new account" height="18" border="0" width="120">
</td>
</tr>
</tbody></table>
</td>
Above html code creates a 1 pixel shadow right under the second image. Please see attached picture and red arrow pointing to 1 pixel line.
Thank you for your help in advance!
<img src="..." style="margin-top:0px;">

HTML table in <a> tag

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">