1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Link in image makes the whole DIV a link. Do not want.

Discussion in 'HTML & Website Design' started by pictureboarduk, Jul 30, 2009.

  1. #1
    Hi,

    I am trying to make an image a clickable link, but when I added the code in bold, it made all the div's contents a link to the URL, not just the image.

    Has anyone any ideas on this? I'm kinda confused as to why this is happening.

    Many thanks or nay help, it's really appreciated. :)
     
    pictureboarduk, Jul 30, 2009 IP
  2. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You did not close the <a> tag. You must add </a> after the image.

    It seems like you are using XHTML standards in your code. Just so you know, target="_blank" is not valid XHTML, as that was removed in the HTML to XHTML transition. (If you are not using the XHTML strict doctype, then you can ignore this)
     
    AssistantX, Jul 30, 2009 IP
    pictureboarduk likes this.
  3. jagged

    jagged Peon

    Messages:
    253
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    damn those </a> tags hahaha i hate when that happens
     
    jagged, Jul 30, 2009 IP
    pictureboarduk likes this.
  4. grandllama

    grandllama Greenhorn

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #4
    Wow, I go back to client server for a few years and when I come back to the web they don't allow _blank. Thanks for the heads up... gotta keep reviewing these standards.
     
    grandllama, Jul 30, 2009 IP
    pictureboarduk likes this.
  5. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, since XHTML (strict) does not support the target="_blank" attribute for links, websites have moved toward using rel="external". XHTML does not have many restriction on the use of 'rel' which is supposed to define the relationship that link has to the current page. 'rel' is allowed to hold any value(s), including "external". To get your browser to open a link in a new window, you must use Javascript. Using Javascript, you can set all links that have rel="external" to open in a new window.
     
    AssistantX, Jul 30, 2009 IP
  6. pictureboarduk

    pictureboarduk Well-Known Member

    Messages:
    551
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Thanks everyone for your help.

    Feeling most embarrassed at the missed </a> tag!
     
    pictureboarduk, Jul 31, 2009 IP