Forum Moderators: not2easy
The DIV has only paragraphs and images in it.
<DIV class="123">
<p><img class="abc">Alpha</p>
<p><img class="abc">Beta</p>
...
<p><img class="abc">Omega</p>
</DIV>
All the images between the DIV tags use class "abc" to define their width, alignment and boarder. No images outside the DIV use class abc.
Is it possible to somehow define the images in the DIV to have a certain class, without having to call that class each time I call an image?
Like...
<DIV class="123">
<p><img>Alpha</p>
<p><img>Beta</p>
...
<p><img>Omega</p>
</DIV>
Thanks
Is it possible to somehow define the images in the DIV to have a certain class, without having to call that class each time I call an image?
Yes, however first we have to clear up a minor problem with the code sample you posted. CSS id's and classes cannot begin with a number, so the div cannot have a class="123". Let's change that to class="xyz" and take it from there...
<DIV class="xyz">
<p><img>Alpha</p>
<p><img>Beta</p>
...
<p><img>Omega</p>
</DIV>
Given the above code, you can target styles to any image within the XYZ class by using the descendant selector [w3.org]...
.xyz img{
float:left;
width:200px;
}
This rule block says, "Apply these styles to any image nested anywhere inside of an element with the class 'xyz'."
cEM