link a background-image / div

M

Marco Lehmann

hi guys,

i have a div, in which a table and a text is located.
with css i defined a background-image laying under the div.
now i want to link the whole div with an a-tag.
w3c's validator says, that a construct like:

<a href="...">
<div id="...">
<table ...>
...
</table>
</div>
</a>

isn't valid because the div-tag seams to be misplaced
inside the a-tag.
i got this validation message:

document type does not allow element "DIV" here; missing one of
"APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag

what's the solution?
thanks in advance.

marco
 
S

Steve Pugh

Marco Lehmann said:
i have a div, in which a table and a text is located.
with css i defined a background-image laying under the div.

Okay, might be a bit over-complex but okay.
now i want to link the whole div with an a-tag.

You can't do that.
w3c's validator says, that a construct like:

<a href="...">
<div id="...">
<table ...>
...
</table>
</div>
</a>

isn't valid because the div-tag seams to be misplaced
inside the a-tag.

Yup.

Don't nest the <div> inside the <a>. Without knowing more about your
page (such as what data goes into the table and why you want an entire
table full of data to be a single link) it's hard to suggest an
alternative.

Steve
 
M

Marco Lehmann

Hi Steve,

the only reason for linking a whole layer is,
that I probably have to change the text nested in the
table several times and I don't want to create a
graphic over and over again.

Here is the complete listing of the relevant part:

<a href="specials.html" class="tabLink">
<div id="specialTab">
<table width="100" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="100" height="40">
&nbsp;<br>
</td>
</tr>
<tr>
<td width="100" height="20">
Specials<br>
November 2003<br>
</td>
</tr>
</table>
</div>
</a>

Hopefully this will help a little bit.
Thanks in advance.

Marco
 
D

David Dorward

Marco said:
Here is the complete listing of the relevant part:

<snip>

Why is there a table there at all? I can't believe you possibly want to
describe a relationship between a non-breaking space with a line break and
what looks like a heading.
 
M

Marco Lehmann

David said:
Marco Lehmann wrote:




<snip>

Why is there a table there at all? I can't believe you possibly want to
describe a relationship between a non-breaking space with a line break and
what looks like a heading.

The div will be moved while the mouse cursor is over the
table. Therefore the div consists of a table, which
arranges the text and the space in the right way. The
distance between the top of the div and the text must be
exact.

Marco
 
T

Toby A Inkster

Marco said:
<a href="...">
<div id="...">
<table ...>
...
</table>
</div>
</a>

Not allowed. You might technically be able to do this:

<a href="...">
<object>
<div id="...">
<table ...>
...
</table>
</div>
</object>
</a>

but this is likely to perform strangley in some browsers. Better to just
link the content of each table cell.
 

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,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top