tags:

views:

178

answers:

7

i already have a css section:

.leftMemberCol
{
width:125px;
vertical-align:top; 
padding: 13px;
border-width:0px;
border-collapse:separate;
border-spacing: 10px 10px;
text-align:left;
background-color:#f2f3ea;
}

for a td section (a left side bar). I want to make all of the links inside this cell be the color green.

is there any syntax like:

.leftMemberCol.a
{
color:#E3E3CA; 
}

or any other suggestions instead of having to go to each page and wrapping all the links around another class name.

+5  A: 

Just do:

.leftMemberCol a
{
   color:#E3E3CA;  
}

That will select all anchor tags nested within the element with the class of .leftMemberCol

Kezzer
this works for all other items such as font-size, etc but for color it doesn't seem to take effect. it stays as the regular link blue color
ooo
you probably need to add a:visited style as well
roryf
A: 

replace the last dot with a space

.leftMemberCol a {
  style goes here
}

The dot indicates a class. A hash indicates an id (

 <div id="home">

can be styled with

#home { }

). A regular html element, like a td or a doesn't need a prefix.

Litso
A: 
.leftMemberCol a
{
    color:#E3E3CA;  
}

This targets all <a> elements that are descendents of .leftMemberCol

roryf
A: 
 .leftMemberCol>a
 {
 color:#E3E3CA;  
 }
DanDan
Using the child selector is unlikely to be wanted here. The links might not be direct children of the table cell.
DisgruntledGoat
A: 

You are very close. This is how you select the links inside the cell:

.leftMemberCol a
{
   color: #E3E3CA;  
}

You can read more about selectors here.

Edit:
If the style doesn't take effect, it's probably because you have some other style defined for the links that is more specific. You can make the style more specific by adding specifiers, for example:

td.leftMemberCol a
{
   color: #E3E3CA;  
}

As a last resort you can also use the !important directive:

.leftMemberCol a
{
   color: #E3E3CA !important;
}
Guffa
A: 
.leftMemberCol a
{
color:#E3E3CA;  
}

should do the trick.

Christian Hayter
LOL - must... type... faster... (gasp!)
Christian Hayter
I notice that someone has voted down my answer and several other answers for this question. Would this person like to provide a reason in the comments?
Christian Hayter
no idea why, so have an upvote on me ;)
roryf
Thanks Rory, very kind of you :-)
Christian Hayter
+3  A: 

If the color doesn't work, check if you set it earlier on in your CSS file for any of the pseudo selectors of the a tag, i.e. a:link etc.

override them using

.leftMemberCol a:link,
.leftMemberCol a:hover,
.leftMemberCol a:visited,
.leftMemberCol a:active
{
   color: #E3E3CA;  
}
Colin
I would also suggest setting some default link colours, using similar code but without `.leftMemberCol` at the beginning.
DisgruntledGoat