What's wrong with this code?

J

Jeff Castaldo

I'm going crazy over this "simple" code. Why will the top code work exctly
as I want it to, and the lower code will not work at all, with or without
the _blank?

This works:
<a href="images/product_images/4870_lg.jpg" target="_blank" /><img
src="images/product_images/4870_t.jpg" /></a>

This doesn't:
<td><a href="images/product_images/4870_lg.jpg" /><img
src="images/product_images/4870_t.jpg" /></a></td>

The ONLY dfference between the code is that in one I am trying to make the
link clickable inside a table cell. Is there something wrong with that?

Thank you for helping.

Jeff
 
N

Neredbojias

I'm going crazy over this "simple" code. Why will the top code work
exctly as I want it to, and the lower code will not work at all, with
or without the _blank?

This works:
<a href="images/product_images/4870_lg.jpg" target="_blank" /><img
src="images/product_images/4870_t.jpg" /></a>

This doesn't:
<td><a href="images/product_images/4870_lg.jpg" /><img
src="images/product_images/4870_t.jpg" /></a></td>

The ONLY dfference between the code is that in one I am trying to make
the link clickable inside a table cell. Is there something wrong with
that?

It might have to do with the (incorrect) trailing slash on the <a> tag.
 
D

dorayme

"Jeff Castaldo said:
I'm going crazy over this "simple" code. Why will the top code work exctly
as I want it to, and the lower code will not work at all, with or without
the _blank?

This works:
<a href="images/product_images/4870_lg.jpg" target="_blank" /><img
src="images/product_images/4870_t.jpg" /></a>

This doesn't:
<td><a href="images/product_images/4870_lg.jpg" /><img
src="images/product_images/4870_t.jpg" /></a></td>

The ONLY dfference between the code is that in one I am trying to make the
link clickable inside a table cell. Is there something wrong with that?

That is not the only difference I see.

If you make them the same and go:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
</head>
<body>
<p><a href="http://www.guardian.co.uk/sudoku"><img
src="pics/crimson.png" alt=""></a></p>
<table>
<tr>
<td><a href="http://www.guardian.co.uk/sudoku"><img
src="pics/crimson.png" alt=""></a></td>
</tr>
</table>
</body>
</html>

This should make the link clickable in the cell as with the one
not in a table cell.

Ditto:

if you add target="_blank" to them both. (Validation in this case
is another matter)
 
J

Jeff Castaldo

Actually, I've found that BOTH codes work perfectly in Firefox and Opera, so
it is definetly an IE6 problem. I do not have IE7 installed on this
machine, so I cannot test with it.

Now, does anyone have a coding "fix"?

Thanks very much.

Jeff
 
B

Beauregard T. Shagnasty

Blinky said:
So why - as OP asked - does one work and one not work?

I copied the OP's code into a local page, and it works, for both
iterations. In several browsers, including IE6.

I did add <table><tr> around the second, and substituted my own image
for both, as I do not have the OP's images, of course.
 
R

rf

Beauregard T. Shagnasty said:
I copied the OP's code into a local page, and it works, for both
iterations. In several browsers, including IE6.

I did add <table><tr> around the second, and substituted my own image
for both, as I do not have the OP's images, of course.

All the more reason for the OP to supply a URL.

No URL - guesswork. URL - point out the error immediately, rather than
beating around the bush for half a day, as we all are.

OP: Big Bloody Hint!

The only saving grace is that the OP is not a google grouper.
 
J

Jukka K. Korpela

Scripsit Jeff Castaldo:
I'm going crazy over this "simple" code.

Then replace it with simple code.
Why will the top code work
exctly as I want it to, and the lower code will not work at all, with
or without the _blank?

By accident. By browser errors. Browsers don't process your markup by
HTML rules _or_ by XHTML specifications but by tagsoup rules. But why
would you care? Just use reasonable markup, and let browsers do
unreasonable things with unreasonable markup.
This works:
<a href="images/product_images/4870_lg.jpg" target="_blank" /><img
src="images/product_images/4870_t.jpg" /></a>

Consider it a bug, or the result of a mixed collection of bugs.

Use correct markup:

<a href="images/product_images/4870_lg.jpg"><img
src="images/product_images/4870_t.jpg" alt="Photo of product 4870"></a>

(The target attribute was omitted here because it "works" so badly when
it works. By omitting it, you give users a simple option of deciding
whether they open the resource in the same window, possibly in a new
pane, or in a new window.)
 
D

dorayme

"Jukka K. Korpela said:
Scripsit Jeff Castaldo:


Then replace it with simple code.

As I said in the first place. And gave example. Thanks JK, I
hope, as we discussed over coffee yesterday, this galvanises the
OP. My examples and thoughts and your authority. What a
combination. Like a left jab followed by a big swing right. I
knew our double act would just go on and on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top