Solved

Image SRC in CSS?

Posted on 2003-12-01
4
704 Views
Last Modified: 2013-11-19
Is there a way I can define the SRC of an Image tag in CSS?

Please note:
I have already tried using the background-image property, but it doesn't solve the fact that I don't declare the src and thereby shows an image marker in IE for the placeholder with the correct image in the background... thus not a good solution.
0
Comment
Question by:yleviel
  • 2
4 Comments
 
LVL 31

Expert Comment

by:seanpowell
ID: 9853484
>>but it doesn't solve the fact that I don't declare the src

You can't have an image if you don't declare the source, CSS or otherwise...
0
 
LVL 15

Accepted Solution

by:
Timbo87 earned 25 total points
ID: 9853538
You can set the properties of the image with CSS, but you cannot specify the src with CSS.

<img style="border:0;width:300px;height:200px" src="mypic.jpg">

If you need to change the src in the life of the document you could do that with JavaScript.
0
 
LVL 2

Author Comment

by:yleviel
ID: 9853606
the whole point is to allow a user to define their own images in a single sheet rather then having to find and replace each case.
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9853657
You could have the user set custom images with cookies.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now