HTML Links in Stylesheet Question

Discussion in 'Programming' started by jawinn, Aug 19, 2009.

  1. #1
    I have 2 images on a site. They are background images that are called up through the style sheet. I need to add links to these images.

    What is the code to do that?

    Here is the current CSS code:

    
    #f01{background: url(../images/f01.png) no-repeat 0 0;position:absolute;left:0;top:0;width:159px;height:79px;}
    #f02{background: url(../images/f02.png) no-repeat 0 0;position:absolute;right:0;top:0;width:146px;height:79px;}
    
    Code (markup):
    Thanks,
    J
     
    jawinn, Aug 19, 2009 IP
  2. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    btw you might wana put a quote around the urls (ie: url('../images/f02.png'))

    Also not sure how you mean link the css, if the image has an id of #f01

    
    <img src="..." id="#f01" ...> you would wrap <a href="..."> </a> around it to make a link. 
    
    Code (markup):
    If they are backgrounds, then you need to make it a background of an object that can be wraped with an anchor.

    Or... you can make links themselves have backgrounds, for example an anchor with an id of f00.

    
    #foo { text-indent: -9999px; display: block; width: 159px; height: 79px; background: url(../images/f01.png) no-repeat 0 0;position:absolute;left:0;top:0; }
    
    <a href="yadayada" id="f00">Some text that won't be seen</a>
    
    Code (markup):
    Essentially what has been created is what appears to be a clickable image.
     
    kblessinggr, Aug 19, 2009 IP
  3. jawinn

    jawinn Active Member

    Messages:
    1,024
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    88
    #3
    I want to have a link to other pages. If they were just normal images in the page I could do that, but I don't know what the CSS code is to turn them from images into images that link to another page when you click on them.
     
    jawinn, Aug 19, 2009 IP
  4. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4

    I edited my post right when you replied. CSS has no properties for "link" by the way, its a style sheet.
     
    kblessinggr, Aug 19, 2009 IP