Forum Moderators: not2easy

Message Too Old, No Replies

Specify css based on class

         

andrewsmd

6:17 pm on Mar 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a CMS system that is generating some links. I need to tell this link to be a different color, but it is generated by the CMS. It looks something like this.

<div class="myClassHere">
<a link="someLink">Some Link</a>
</div>

What I'm wondering is if there is a way to tell the link in myClassHere to do something different than the default
a{
/*css here*/
}
That I have defined. Can I do this with something like myClass.a{

}
or something like that? Thanks,

TheMadScientist

6:45 pm on Mar 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Something like this should be what you're looking for:

.myClass a {
/* style here */
}

andrewsmd

6:53 pm on Mar 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks

rocknbil

10:01 pm on Mar 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With TheMadScientist's solution you're probably better off removing the class from the anchor, it's not needed, like

<div class="myClassHere">
<a href="">Some Link</a>
</div>

but if the CMS generates it and you can't remove the class, it would be more specific to do

<div class="myClassHere">
<a link="someLink">Some Link</a>
</div>

.someLink {
/* style here */
}

Or even,

.myClassHere .someLink {
/* style here */
}

Which becomes important if you have other links in myClassHere that you don't want styled by .someLink.