Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How Do I Change An Image on an HTML Page via the CSS sheet?
The reason i want to do this from the CSS is that i have a script that loads A DIFFERENT css depending on region/where the visitor is coming from
ie i want to present a different image to those in different regions by loading different style sheets depending on the region.
I then simply change the image in each style sheet to suit.
I am trying to change an html image as indicated below:
The code below was taken by right clicking the image i want to change and choosing inspect element. THIS IS THE CODE OF THE IMAGE on an HTML page.
I want to REPLACE THIS IMAGE::
<img width="462" height="62" alt="" class="art-lightbox"
src="images/changethispicture.png" style="">
WITH THIS:
<img width="462" height="62" alt="" class="art-lightbox"
src="images/tothispicture.png" style="">
But i want to do it through the style sheet.
can This Be Done?
Please note i am not a programmer of any sorts so please speak in easy english. Thanks
PS, the index.html page loads the home.html page. If what i am trying to do could be applied to making a different choice of the home.html page, ie home2.html instead then id be interested to hear your thoughts on the ways this can be done.
Obviously the code wold have to override the default home.html with the new home2.html
2 Answers
- 8 years agoFavorite Answer
Instead of the <img> tag you would want to use a <div> tag but add the CSS property 'background-image'.
i.e:
HTML:
<div id="CHANGETHIS"></div>
CSS Stylesheet 1:
#CHANGETHIS{
background-image:url(http://yourimage.com/image.jpg);
width:462;
height:62;
}
Then you could change the stylesheet to
CSS stylesheet 2:
#CHANGETHIS{
background-image:url(http://yourimage.com/different-image.jpg);
width:462;
height:62;
}
I can't think of any other way you could do it. If you want help with any other bits I'd be happy to help. I am fairly good with HTML/CSS. My email is danny_arthur@hotmail.co.uk
Source(s): I make websites in my spare time. - 4 years ago
IE8 helps you to simulate previous variations of IE to work out how the internet site renders. wanting that, the only other way is to have separate attempt machines, or separate put in cases of domicile windows, each and every featuring a distinctive browser to objective with.