Forum Moderators: not2easy

Message Too Old, No Replies

Exclusive CSS

applies to all except...

         

sssweb

6:36 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



Is there a way to apply a CSS rule to a class of text EXCEPT for one instance of that class?

I'm using a 'no underline' rule on links, but I need to exclude one instance.

The problem is that the page is a PHP template, and the text that I want to exclude from the rule is inserted by the PHP from another file; so I don't think I can override the rule at the text itself (if anyone knows how to do that, it's an acceptable alternative).

So far, I've got this basic code in my header:

a { text-decoration: none }

encyclo

6:48 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you can modify the code itself, you can just add a
style
attribute directly on the link:

<a href="link.html" [b]style="text-decoration:underline;"[/b]>link text</a>

sssweb

6:55 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



That's the thing, I can't modify the text. It's generic text that gets pushed into many different templates. It comes in with the links underlined, which it should. But on this particular page, I need to remove all link underlines EXCEPT that one.

encyclo

6:59 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the particular link within an identifiable block, such as a header or a div with a particular id or class name? The basic idea is to find a way of targetting the one link by writing a rule that could only apply to that one element.

What does the section of markup look like?

sssweb

7:18 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



It's in a <span> block within a table cell. The span already has a class spec; I tried adding 'id', but as I said, it didn't override the PHP insert. Here's the section of code:

<td><span class="nav">{PAGINATION}</span></td>

As you can see, it's a pagination block that has page links. I'm displaying this on a print-friendly page on which I want to remove all links, EXCEPT the pagination block, which the user needs to navigate (while the print page is still on the screen).

encyclo

7:22 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anything else use the class name "nav"?

a {
text-decoration:underline;
}

td .nav a {
text-decoration:none;
}

sssweb

7:44 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



That worked! You had the spec switched around; I changed it to:

td .nav a {
text-decoration:underline;
}

Thanks a lot. :)

encyclo

7:58 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem - the above rule is very specific to the context you gave. If no other link on the page is included within an element with the class name "nav", then you only need to define the rule for the class:

.nav a { 
text-decoration:underline;
}

sssweb

8:13 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



Okay -- that works too; I'll use that.

Thanks again...you live up to your name. :P