leora
leora

Reputation: 196589

Styling All Anchor Tags Within A <td> Element

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.

Upvotes: 2

Views: 5868

Answers (7)

Colin
Colin

Reputation: 10638

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;  
}

Upvotes: 4

Guffa
Guffa

Reputation: 700422

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;
}

Upvotes: 0

Christian Hayter
Christian Hayter

Reputation: 31071

.leftMemberCol a
{
color:#E3E3CA;  
}

should do the trick.

Upvotes: 0

roryf
roryf

Reputation: 30160

.leftMemberCol a
{
    color:#E3E3CA;  
}

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

Upvotes: -1

DanDan
DanDan

Reputation: 10562

 .leftMemberCol>a
 {
 color:#E3E3CA;  
 }

Upvotes: -1

Stephan Muller
Stephan Muller

Reputation: 27610

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.

Upvotes: 0

Kieran Senior
Kieran Senior

Reputation: 18220

Just do:

.leftMemberCol a
{
   color:#E3E3CA;  
}

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

Upvotes: 5

Related Questions