5 replies [Last post]
sohrabx
Offline
newbie
Last seen: 16 years 16 weeks ago
Joined: 2003-08-19
Posts: 6
Points: 0

Hi,

I had a question: as far as using pictures, is it proper practice to place pictures only inside the css file, only inside the html file, or both?

I'm getting the impression that you should pretty much put it all inside the css file, however, that makes me wonder about stuff like javascript rollover links, how would that work?

Thanks for the help,

-Sohrab

Pob
Offline
Enthusiast
Hampshire UK
Last seen: 8 years 26 weeks ago
Hampshire UK
Timezone: GMT+1
Joined: 2003-08-16
Posts: 60
Points: 5

Pictures: <img> Proper Practice: place in CSS file or

Hi,

You can only place background images in your css file, although this may suit for a lot of purposes.

There is nothing wrong with including images in your html, just as there is nothing wrong with including text in your html.

In fact for accessibility its better to have important images in the foreground and make sure that they have their alt and title attributes defined.

Paul

sohrabx
Offline
newbie
Last seen: 16 years 16 weeks ago
Joined: 2003-08-19
Posts: 6
Points: 0

Thanks. Very clear reply! :)

Thank you for your reply, it is most appreciated Smile

-Sohrab

exorcyze
Offline
Regular
Last seen: 16 years 18 weeks ago
Joined: 2003-07-30
Posts: 18
Points: 0

Pictures: <img> Proper Practice: place in CSS file or

I would agree with Pob. However, to play devils advocate and provide some food for thought:

CSS is for defining the presentation of your site, and images could very well be classified under presentation. If you look at something like CSS Zen Garden (http://www.csszengarden.com/) you can see there are no images in the HTML, which gives them the power to restyle it so completely and dramatically using only CSS...

Smile

Pob
Offline
Enthusiast
Hampshire UK
Last seen: 8 years 26 weeks ago
Hampshire UK
Timezone: GMT+1
Joined: 2003-08-16
Posts: 60
Points: 5

Pictures: <img> Proper Practice: place in CSS file or

Hi,

I ageree with exorcyze that presentation should be separated from content Smile .

If the presentation is in the form of images then this is fine in the CSS. I was thinking more of images that are pertinent to the content and add something to the content.

Alt and title attributes are important to screen readers and the like (and I believe also to search engines as well). Whereas background images in the CSS are ignored by both.

So I agree and disagree at the same time (if that's possible) Wink.

Paul

inababes
inababes's picture
Offline
Regular
Last seen: 16 years 18 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

Re: Pictures: <img> Proper Practice: place in CSS file

i agree with what has already been said about separating content from presentation, although i don't see anything wrong with a few images in the html. it's nicer to keep the majority in the background, to make for skin switching ala CSS zengarden. Laughing out loud

sohrabx wrote:
however, that makes me wonder about stuff like javascript rollover links, how would that work?

as for javascript rollover links, well you can use pure CSS rollovers.