0

I have links in a table.
like:

<table>
 <tr>
   <td><a href="lalala"></a></td>
   <td><a href="lalala"></a></td>
   <td><a href="lalala"</a></td>
   <td><a href="lalala"></a></td>
 </tr>
</table>

I want to use mutliple classes:

<td class="XYtableItem itemID"><a href="lalala" /></td>

The problem is: I cant reach the a elements in CSS I tried these:

.XYtableItem a {}
a.XYtableItem {}
XYtableItem > a {}

none of these works. I dont rly know this should work or not. +I cant put classes to the a elements, but doesnt matter, not working eiter.

2
  • The closing <a> tag is missing... is that in your original code? Commented Aug 22, 2011 at 12:06
  • FF,Safari,IE.. not the original, it is just an example. Commented Aug 22, 2011 at 12:08

5 Answers 5

1

They should work, out of curiosity what CSS rules are you trying to apply to the link ? Bare in mind that there may be some other rules in the CSS overriding your ones, giving you the impression you're not targeting the link correctly.

.XYtableItem a

This one should be good

Sign up to request clarification or add additional context in comments.

Comments

1

The first rule should match as that selects any a element that is the descendant of an element with the XYtableItem class.

The second rule will any a with the class XYtableItem and the third any a element that is a descendant of a XTtableItem element - possibly just missing the class selector (.).

Try adding content to your a tag as it shouldn't be self closing.

Example at http://jsfiddle.net/mfhHG/

Comments

0

As other answers suggest, most probably your style might be overriding by something else.. You firebug to inspect the element and trace the style.. it should show you what exactly is being overridden by which style..

Comments

0

There are some problems with your HTML,

<table>
 <tr>
   <td><a href="lalala">Link</a></td>
   <td><a href="lalala">Link2</a></td>
   <td><a href="lalala">Link3</a></td>
   <td><a href="lalala">Link4</a></td>
 </tr>
</table>

And the selectors should be very simple.

Check this example.

Comments

0
<style>
    td.aaa a {
        color: green;
    }
    td.bbb a {
        color: yellow;
    }
</style>

<table>
    <tr>
        <td class="XYtableItem aaa"><a href="lalala">aa</a></td>
        <td class="XYtableItem bbb"><a href="lalala">bb</a></td>
    </tr>
</table>

The above works for me. (Although I have had some problems with some styles like padding etc when using on a tags on IE)

1 Comment

probably because your anchor tags were empty.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.