In an ideal world, all graphics and layout are defined in style sheets - but not <img> src? Must not be?

The goal of CSS is to help web developers identify and apply graphics and layout that are separate from the actual content.

However, it looks like CSS can customize almost anything (graphic image) on a website - besides the original <img>-tag attribute .

To achieve a 100% separation between style and content (what do we all want, right?), Should we not define image sources in CSS?

I know that CSS cannot do this (there is no support for changing the src attribute for images), but there are workarounds such as using <div>with backgrounds instead <img>. However, by doing this, will it not break the search engines?

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

+5
source share
6 answers
Tags

<img />Designed for content, not style.
<img />supposed to be used for something like a photograph accompanying an article.

UI graphics must be done using CSS backgrounds.

+14
source

An image is content — for example, charts. Style is just to make the page beautiful, but it does not add anything to the content (syntax / semantics) of the document.

+2
source

, ... img.

+1

.

+1

, , CSS, .

Images that are part of the content must be inline img tags.

+1
source

It depends on when. Sometimes images are happy, not style. Therefore, you can use a div with css backgrounds if it is purely for style, but use a tag when you want to display an image of content.

Then you really will have a 100% separation of content / style.

+1
source

All Articles