Image links with XHTML

  • Thread starter Luigi Donatello Asero
  • Start date
L

Luigi Donatello Asero

How do I link an image with XHTML?
I thought I should use a close tag after <a href> and one after <img src>
but it seems as if I have misunderstod something because the link does not
seem to
work on the page www.scaiecat-spa-gigi.com/sv/test.html
<a href="ullasbrev.html"></a><img src="../bilder/ullasbrevlite.jpg"
width="90" height="120" alt="Ulla och Bengt har skickat detta brev"></img>
 
M

Matthias Gutfeldt

Luigi said:
How do I link an image with XHTML?
I thought I should use a close tag after <a href> and one after <img src>
but it seems as if I have misunderstod something because the link does not
seem to
work on the page www.scaiecat-spa-gigi.com/sv/test.html
<a href="ullasbrev.html"></a><img src="../bilder/ullasbrevlite.jpg"
width="90" height="120" alt="Ulla och Bengt har skickat detta brev"></img>

Image links are the same as text links, with the difference that you're
using and image instead of the text. A text link is like this:

<a href="blah.html">Link text</a>

But what you did is this:

<a href="blah.html"></a> Link text

That, of course, can't work because the "Link text" is not part of the A
element's content.

Therefore your image link has to be like this (put on separate lines for
illustration):

<a href="ullasbrev.html">
<img src="../bilder/ullasbrevlite.jpg" width="90" height="120" alt="Ulla
och Bengt har skickat detta brev"></img>
</a>
 
S

Steve Pugh

Luigi Donatello Asero said:
How do I link an image with XHTML?

The same way that you would in HTML.
I thought I should use a close tag after <a href>

Why? Is said:
and one after <img src>
but it seems as if I have misunderstod something because the link does not
seem to work on the page www.scaiecat-spa-gigi.com/sv/test.html

<a href="ullasbrev.html"></a><img src="../bilder/ullasbrevlite.jpg"
width="90" height="120" alt="Ulla och Bengt har skickat detta brev"></img>

That's the same as the HTML

<a href="ullasbrev.html"></a><img src="../bilder/ullasbrevlite.jpg"
width="90" height="120" alt="Ulla och Bengt har skickat detta brev">

You want -
<a href="ullasbrev.html"><img src="../bilder/ullasbrevlite.jpg"
width="90" height="120" alt="Ulla och Bengt har skickat detta brev"
/></a>

Steve
 
L

Luigi Donatello Asero

brev"> said:
Image links are the same as text links, with the difference that you're
using and image instead of the text. A text link is like this:

<a href="blah.html">Link text</a>

But what you did is this:

<a href="blah.html"></a> Link text

That, of course, can't work because the "Link text" is not part of the A
element's content.

Therefore your image link has to be like this (put on separate lines for
illustration):

<a href="ullasbrev.html">
<img src="../bilder/ullasbrevlite.jpg" width="90" height="120" alt="Ulla
och Bengt har skickat detta brev"></img>
</a>
 

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

Forum statistics

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

Latest Threads

Top