How to add a link for the image on style css?

Discussion in 'CSS' started by zm21, Nov 27, 2008.

  1. #1
    Hello,

    This is the code of a picture on my all html pages which is placed on my style css:

    #headermiddleredPan{width:154px; height:154px; background:url(images/xyz.jpg) 0 0 no-repeat; position:absolute; top:14px; left:492px;}

    I want to add a link to this image so that users can click the image and go to the website of that link url. How can I do that with the style css sheet? What code should I add to the above code? :confused: I also want the link as "blank", I mean the link should open in a new window.

    Thanks.
     
    zm21, Nov 27, 2008 IP
  2. belkocrnic

    belkocrnic Active Member

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    in html <a href="http://forums.digitalpoint.com"><img src="img.jpg" alt="img"/></a>

    and i reccomend in css for the image add border:0
     
    belkocrnic, Nov 27, 2008 IP
  3. snake charmer

    snake charmer Guest

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <a href="http://www.THEWEBSITE.com" target="_blank"><img src="images/THEIMAGE.jpg" alt="Truck" /></a>

    put that in your html

    if you want no border on the image add border="0" inside the image tag or if you want to put it in css you can create a new class like

    .noborder{
    border:0px;
    }

    then add the class="noborder" inside the image tag.
     
    snake charmer, Nov 28, 2008 IP
  4. Sensei.Design

    Sensei.Design Prominent Member

    Messages:
    3,847
    Likes Received:
    162
    Best Answers:
    0
    Trophy Points:
    310
    Digital Goods:
    1
    #4
    there is no way to di it with css ;) you need to do it in html like belkornic explaned and make sure you use the image and not a div tag bc thats not valid ;)
     
    Sensei.Design, Nov 28, 2008 IP