#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Michigan, USA
    Posts
    278
    Rep Power
    17

    vary image with css?


    is there any way to change the image that is used in a <img> tag with css?

    something like this...

    Code:
    img.image
    {
      image: url(image.jpg);
      width: 100px;
      height: 100px;
    }
    
    
    <img class="image" alt="blah" />
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    Not really. CSS was developed to seperate content from layout.

    CSS being for layout and HTML for content.

    What are you looking for? A random image display?
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Michigan, USA
    Posts
    278
    Rep Power
    17
    no i just wanted to have different stylesheets for my past layouts of my site
  6. #4
  7. what's your moniker?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Highland Park, NJ
    Posts
    201
    Rep Power
    11
    Ok, well what you want to do, is use css image replacement. Basically you make a div with a background image specified as well as height and width. also define a span with {display:none}

    in the html put

    <div id="image"><span>alt text</span></div>

    the benefit is that you can change the image in the style sheet, without changing the html.

    the downside is search engines like to see IMG tags, and the lack of any could hurt you in the SERPs

    Merry Freaking Xmas!!!

IMN logo majestic logo threadwatch logo seochat tools logo