Web Hosting Talk







View Full Version : CSS question


croakingtoad
11-18-2003, 03:29 AM
Is it possible to 'nest' css elements using the <div> tag?

For example, say I want every instance of anchor statements <a> within a specific <div> class to apply a certain style to them?

IE:

<div class="special">

<a href="foo.html">Foo</a>
<a href="oof.html">Oof</a>

</div>

So, I have declared a style for the <div> and is it possible within the stylesheet to associate styles for the <a> tags without having to specify them using the class statement? Of course, all other tags within the document (outside the <div>) would maintain their normal state. Somewhat like the :first-child pseudo-element...?

Thanks in advance!

Burhan
11-18-2003, 03:35 AM
If you were to read up on CSS you would learn that the C in CSS stands for Cascading, which means that the style for the parents apply to child elements.

For your example,

.special a:link { color:red; }

etc.

croakingtoad
11-18-2003, 03:42 AM
I knew there must be a way to do it, I just wasn't sure of the syntax, thanks!

Burhan
11-18-2003, 03:51 AM
no problem :D

If you ever want to know more about CSS -- you can always get information from the horse's mouth (http://www.w3.org/Style/CSS)