views:

65

answers:

3

Hi there.

I'm actually coding a website and a doubt came to me. I have a list of images (it's an artist portfolio, so it should be images), some of which have a "Featured" badge. Is it semantically correct to wrap the img into a strong tag instead of using a class="featured"? Will it add strong emphasis to the image?

Reading the W3C spec., it refers strong and em as text-level semantics, but I'm not sure what happens with media like img.

Thank you so much.

A: 

I think that it would be perfectly acceptable to do this and preferable.

Sqoo
semantics is often about making judgement calls, In this case you are highlighting an image in markup if using a strong tag wheras using a stly mearley differentiates visually. You want this image marked differently in the HTML asfter all,
Sqoo
Yes, that's the point. I think I'll do. Thanks!
Alberto Calvo
A: 

First of all, I think the HTML 4 spec allows it. Question is, can you rely on what browser will do with it. I would not take my chances with that.

But at least, in many browsers you can attach formatting to

strong img {
    /* mark up for the featured image */
}

And this should then work for all browser that support it.

Roland Bouman
Oh, sure. In terms of styling there's no problem. Thanks! :)
Alberto Calvo
BTW: if it's just emphasis you need, you can do `<em><img .. /></em>`. It is completely valid, just like `<strong>`
Roland Bouman
A: 

Hi Alberto, I wouldn't use the strong tag on images, I am not sure why it would be preferable since it refers to 'emphasized' text only: an aural user agent may use different voices for emphasis, it would be pointless for images.

Why don't you just use a class?

Toxinide
Yes, that's exactly my doubt. Dunno if it really adds meaning to media content.And regarding aural user agents, Bruce Lawson pointed this article to me: http://www.paciellogroup.com/blog/?p=41 Interesting...
Alberto Calvo
Ah that's interesting, and a bit more confusing now, I would still go for classes, but that's me :P
Toxinide