Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a perfect world, all the graphics and layout are defined in stylesheets - but not <img> src? Shouldn't be?

Tags:

html

css

web

The purpose of CSS is to help web developers to define and apply graphics and layout, separated from the actual content.

However, it seems like CSS can tweak pretty much anything (graphics wise) on a website - apart from the source attribute of an <img>-tag.

To achieve 100% separation between style and content (which we all want, right?) shouldn't we define image sources in the CSS as well?

I know that CSS can't do this (no support of changing src-attribute for images) but there are work-arounds, such as using <div> with backgrounds instead of <img>. However, by doing that, won't it break search engines?

My question is. Is using instead of <img> to achive 100% separation between style and content a reasonable action?

like image 225
corgrath Avatar asked Jan 18 '12 16:01

corgrath


3 Answers

<img /> tags are intended to be content, not style.
<img /> is supposed to be used for something like a photo accompanying an article.

UI graphics should be done using CSS backgrounds.

like image 102
SLaks Avatar answered Sep 30 '22 21:09

SLaks


An image is content - e.g. diagrams. Style is just to make the page pretty but adds nothing to the content (syntax/semantics) of the document.

like image 24
Ed Heal Avatar answered Sep 30 '22 21:09

Ed Heal


Sometimes images are content and not just style... and that's when you use an img tag.

like image 20
canon Avatar answered Sep 30 '22 19:09

canon