[css-d] Why add an .img class?

2005-10-18 Thread Charles Dort
I'm a CSS beginner, slowly working through Dan Cedarholm's _Bulletproof Web
Design_, and (on p. 80, if you also have the book) he inserts class=img
into a dd so he later can reference that class, identifying the dds that
contains an image, as opposed to other dds that contains only text.
Here's an example of each:

 

dd class=imgimg src=img/gamlastan.jpg width=80 height=80
alt=Gamla Stan //dd

 

ddThis was taken in Gamla Stan (old Town) in a large square of amazing
buildings./dd

 

He then addressed this class in the CSS as follows:

 

#sweden dd.img img {float: left;}

 

I didn't see the point of adding the class to the html code because it
seemed to me that it could be identified without it, so I experimented by
leaving out the class and addressing it in the CSS with just

 

#sweden dd img {float: left;}

 

and it seemed to work fine.  But I'm the beginner, and the expert used the
class.  I'm sure there was a reason; I just don't know what it is.  Can
anyone tell me why it's necessary or a good idea to add that class to
identify the image?

 

Thanks!

 

Charles

 

__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] Why add an .img class?

2005-10-18 Thread Gunlaug Sørtun

Charles Dort wrote:

#sweden dd.img img {float: left;}



I didn't see the point of adding the class to the html code because
it seemed to me that it could be identified without it, so I
experimented by leaving out the class and addressing it in the CSS
with just



#sweden dd img {float: left;}



and it seemed to work fine.  But I'm the beginner, and the expert
used the class.  I'm sure there was a reason; I just don't know what
it is.  Can anyone tell me why it's necessary or a good idea to add
that class to identify the image?


I don't see the point either - in that case. (I haven't read the book.)

However, if you have an image in one 'dd' you want to 'float', and an
image in another 'dd' that you _don't_ want to add that style to, then
the extra class on 'dd' can be used to separate them.

You may then of course just as well add a class to the image you want to
'float' itself, in such a mixed case.

Plenty of options available, and every site may need its own strategy
for use of these options. Test them out, and try to keep it simple and
understandable as you go along, as it will be much easier to maintain
later on. (I should have followed that rule myself :-) )

regards
Georg
--
http://www.gunlaug.no
__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] Why add an .img class?

2005-10-18 Thread Choan C. Gálvez

Charles Dort escribió:

I'm a CSS beginner, slowly working through Dan Cedarholm's _Bulletproof Web
Design_, and (on p. 80, if you also have the book) he inserts class=img
into a dd so he later can reference that class, identifying the dds that
contains an image, as opposed to other dds that contains only text.
Here's an example of each:

dd class=imgimg src=img/gamlastan.jpg width=80 height=80
alt=Gamla Stan //dd

ddThis was taken in Gamla Stan (old Town) in a large square of amazing
buildings./dd


Charles,

By adding a `class` to the `dd`, you're adding a hook to style the `dd`, 
 not the image.


So `#sweden dd.img` will affect just the `dd` elements which contain images.


He then addressed this class in the CSS as follows:

#sweden dd.img img {float: left;}


You are styling the `img` here.


I didn't see the point of adding the class to the html code because it
seemed to me that it could be identified without it, so I experimented by
leaving out the class and addressing it in the CSS with just

#sweden dd img {float: left;}


You are still styling the image.


and it seemed to work fine.  But I'm the beginner, and the expert used the
class.  I'm sure there was a reason; I just don't know what it is.  Can
anyone tell me why it's necessary or a good idea to add that class to
identify the image?


As said previously, the class is added to identify the `dd`, not the `img`.

HTH,
Choan

__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] Why add an .img class?

2005-10-18 Thread Rimantas Liubertas
2005/10/18, Christian Montoya [EMAIL PROTECTED]:
...
 That being said, class img is a poor naming convention. Something
 like imgleft would have made more sense. And I would strongly
 discourage naming a class just like an element... I mean, imagine if
 you made a little typo and put img instead of .img ... your whole
 page would probably fall apart.

And just imagine if you decide to float your .imgleft to the right...

Regards,
Rimantas
--
http://rimantas.com/
__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] Why add an .img class?

2005-10-18 Thread Mike Dougherty

define uncluttered

Good markup should describe the content.  If there is semantically correct information about the 
tags that is not immediately used by the current stylesheet, that does not mean the information is 
'clutter.'  I would prefer the content creator add appropriate classes describing the content 
(though not the layout preferences) so that the presentation layer (css) has more opportunity to 
specifically style the content.  It becomes very difficult to later isolate specific elements in a 
document if those elements do not have appropriate classes.



On Tue, 18 Oct 2005 11:45:53 -0400
 Charles Dort [EMAIL PROTECTED] wrote:

MANY thanks to all who have so helpfully replied to my question!

As a beginner, perhaps I've focused too much on the value of uncluttered
markup.

So far as I can see, I was able to complete all of the tasks of that chapter
(including changing margins, etc.) without cluttering the markup with a
class that to this beginner seemed unnecessary.  I would have supposed that
if in the future I made a change such as adding text to the dd with an
image, then I would need a class and could then add it at that point, and I
wondered why do it until/unless it's needed.

I gather from the replies that experienced CSS coders would often prefer to
be prepared for such a possible future need, even though it may mean
adding classes to the html markup that aren't actually needed, at least at
this time.

It's helpful for me to think about these things, and I thank all of you for
your help.

Charles


__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


__
This message was scanned by ATX
12:19:13 PM ET - 10/18/2005


__
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/