Forum Moderators: open

Message Too Old, No Replies

links in netscape - making a whole table cell into a link

         

singularity

9:02 am on May 22, 2002 (gmt 0)

10+ Year Member



how come this works fine in IE, but not in Netscape 6.2?

<a href="somepage.asp">
<tr>
<td>
some text
</td>
</tr>
</a>

I need the whole TR to be a link, but Netscape places the whole link outside the table!?!

btw, i have noticed a pattern when it comes to web design: your first simple idea will most likely work in IE, but Netscape will often require some complicated work-around. For developers, IE is easier to work with.

Nick_W

9:21 am on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because it is wrong ;)
Check it out here: [validator.w3.org ]

You can't have an inline element like <a> containing a block level element like a table, or components of a table.

If you want to have a 'block' around your link text so you get a button like effect you could try something like this:

<div style="width: 20%">
<a href="#" style="display: block;">Some link text</a>
</div>

Hope that helps!

tedster

9:43 am on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It may seem like IE is easier to work with - because it forgives bad code. But in the long run, that's not a good idea.

You get enticed into poor coding habits and you end up with pages that blow up on other browsers - and even pages that chase search engine spiders away because of their errors (spiders are really a lot like a primitive browser!)

Trying to have an inline element contain a block level element is a very frequent cause of code that doesn't validate. Ever seen this?

<font face="Arial, Helvetica">
<p>text text text</p>
<p>text text text</p>
</font>

Same error, but in this case most browsers will forgive it. However, <font> is an inline element (actually "was", since it's deprecated) and cannot legally contain <p>, which is a block level element.

If this whole idea of block level elements and inline elements is new to you, here's a reference:
[htmlhelp.com...]

singularity

9:50 am on May 22, 2002 (gmt 0)

10+ Year Member



Okay, so my original design wasn't 'legal', w3c-wise! :)

But, your suggestion works great in both browsers!

thanx, man!

IanKelley

11:20 pm on May 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The only legal way to do it is with javascript. Fill the cell with a DIV and use the onclick event.