Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Did I type this wrong?

Status
Not open for further replies.

NewbiDoobie

Technical User
Jul 25, 2005
63
US
I cannot seem to change the color of my link via the stylesheet.

This is the statement I am trying to change the link to blue with is:

<p class="main">Go ahead, click on <a class="SubSectLink" href="javascript:document.frmDemo.submit();">Try It Now!</a></p>

The stylesheet looks like this:
<STYLE>
.main
{
FONT-SIZE: 11px;
FONT-FAMILY: Arial, Helvetica, sans-serif
}
.SubSectionHderBlk
{
FONT-WEIGHT: bold;
FONT-SIZE: 11px;
FONT-FAMILY: Arial, Helvetica, sans-serif
}
.SubSectionHderRed
{
FONT-WEIGHT: bold;
FONT-SIZE: 11px;
COLOR: #cc0000;
FONT-FAMILY: Arial, Helvetica, sans-serif
}
.header
{
FONT-WEIGHT: bold;
FONT-SIZE: 14px;
FONT-FAMILY: Arial, Helvetica, sans-serif
}
BODY
{
BACKGROUND-COLOR: #cccccc
}
A:link
{
FONT-WEIGHT: bold;
COLOR: blue;
TEXT-DECORATION: underline
}
A:visited
{
COLOR: #000000;
TEXT-DECORATION: none
}
A:hover
{
COLOR: #000000;
TEXT-DECORATION: underline
}
A:active
{
COLOR: #000000;
TEXT-DECORATION: none
}
A.SubSectLink
{
COLOR: blue;
TEXT-DECORATION: underline
}
</STYLE>

 
I need the link to turn blue. It does not do it. How do I get it to work using the stylesheet?
 
I mean, does it work as.
Code:
.SubSectLink
{
    COLOR: blue;
    TEXT-DECORATION: underline
}
 
it is the class in the css for blue links, by default for this site they are not supposed to change, but on this page they are supposed to be blue and underlined.
 
No, it does not seem to work in either case, which is why I think I typed it wrong, but I do not see where
 
I just tested it in FireFox and it shows as it should (blue/underline).
 
Iis this the first/only link on the page? I suspect it's being overridden by the A:active rule - which IE will (wrongly) apply to the link with the focus, instead of to a link that's currently being clicked. Frankly, [tt]:active[/tt] is often more trouble than it's worth.

Try this to be sure...
Code:
A.SubSectLink:link,
A.SubSectLink:visited,
A.SubSectLink:hover,
A.SubSectLink:active,
{
    COLOR: blue;
    TEXT-DECORATION: underline
}
Alternatively, while debugging, give each flavour of [tt]A[/tt] rule a different colour - then you'll know which one's being applied to the link in question.

Oh, and you'll save yourself a world of pain tracking down case-sensitivity errors if you get into the habit of using lower case for everything.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Oh, and you'll save yourself a world of pain tracking down case-sensitivity errors if you get into the habit of using lower case for everything.

I can't even begin to tell you why that statement is just totally WRONG!


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I agree. I use "camel-case" for all my ID and class names - with no problem in any browser.

It's down to the competence of the developer concerned, not the case of the text you happen to use.

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Well, OK, if camel case floats your boat and you can stick to it, use that - but be consistent in whatever scheme you use. I like all-lower 'cos that's how XHTML tags have to be, so it seems easier on my brain to make everything else lower as well.

However, note that the OP already has classes of [tt].SubSectionHderBlk[/tt] and [tt].SubSectionHderRed[/tt] but also [tt].main[/tt] and [tt].header[/tt]. I prophesy a long period of hair-tearing out one day when (s)he writes a page with a [tt]<div class="Main">[/tt] and can't figure out why the CSS isn't being applied.

One of the confusing things about web technologies - (X)HTML, CSS, JS, server-side languages - is that some things are case sensitive, some aren't. The way to stay sane is to pretend everything is case sensitive and act accordingly. all-lower is my favoured approach, but different strokes suit different folks I guess.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top