tags:

views:

78

answers:

2

To set your own colors for anchor, I know we can do this in UserContent.css: a { color:green!important; background-color: white!important; font-size: 1.2em!important; }

But how to set a specific color for the anchor tag that references the same page (the "#" is in the url). Or if "javascript:" is in the ural of the anchor tag?

+2  A: 

Use the attribute-starts-with selector:

a[href^="javascript:"], a[href^="#"] {
    color: red;
}
Andy E
many thanks! especially the link for more information :) But it doesn't work for every site. Will have to read more. Eg. a[href^="javascript:"] { color:red!important; background-color: white!important; font-size: 1.2em!important; } fails for http://www.canada.com/topics/travel/story.html?id=6ee05ca5-7c84-48d1-b007-be5b440ff7de on the link "Print this Article". Firefox bug or more read-up needed -- lets see.
frissony
+2  A: 

Looks like the CSS3 Attribute Selector will work in Firefox 3.0+.

a[href^="#"]
{
  ⋮ declarations
}
HaleFx
+1, Thanks, already read Andy E.
frissony
The example you posted on Andy E's answer probably doesn't work because the link text is inside a "span" element and the default style is more specific for the "span" than the attribute selector alone. Try: a[href^="javascript:"] span { ⋮ declarations }
HaleFx