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 <dd>s that
contains an image, as opposed to other <dd>s that contains only text.
Here's an example of each:

<dd class="img"><img src="img/gamlastan.jpg" width="80" height="80"
alt=Gamla Stan" /></dd>

<dd>This 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/

Reply via email to