...

View Full Version : Semantics



Ibanez
05-27-2009, 10:05 AM
Hi all!

I have a quick question, which is semantically more correct:
Placing an image like this <div><img src="" alt="" title="" /></div>
Or by using CSS as background-image?

I really want to form good habits over here...

thanks!

brazenskies
05-27-2009, 10:51 AM
it depends entirely on what the image is for.

Is it an essential part of the design or it it something that could be replaced by alt text?

Ibanez
05-27-2009, 11:01 AM
Its the header of the page.
There is no vital info in any of my images, but the reason why I asked, is the following:
If you use CSS you are unable to use the alt and title tags, whereas if you place it in your HTML you can. So does that make it more semantic by placing it in your HTML?

frankle
05-27-2009, 11:51 AM
Hi all!

I have a quick question, which is semantically more correct:
Placing an image like this <div><img src="" alt="" title="" /></div>
Or by using CSS as background-image?

I really want to form good habits over here...

thanks!


If it is something which you need to display an image as a background,then you cannot avoid using css as: "background-image:url(images/sample.gif)"

and here "alt" and "title" tag has no choice.

But if images you are placing is not related to background then its advisable you use <img src="images/sample.gif alt"sample" title"sample" /> and give a chance to google image bot to read your image. Especially much better for company logo if it is there in the header.


Regards.

VIPStephan
05-27-2009, 02:35 PM
The question is: Is it crucial for the understanding of the subject/content of the site then the image must be an HTML image. If it has a purely presentational purpose (i. e. is there to make the site look good) but adds no direct informaton (hard facts) then it should be a CSS background.

In this case the header image is only “soft information”. That means it’s not crucial to understand what the site is about but rather adding some “feel” to the page through nice graphics so it should be a background image. You could, for example, have a first level heading (<h1>) as title of your page and apply the image as background to this heading, hiding the default text in that heading (with negative text indent). Users with mobile devices or printing the page would see the plain heading while regular computer screen users will see the background image. This way everybody gets the necessary information.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum