css help required!

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Right, I'm ok with css for baiscs but I'm now starting to get more involved with them and that's where I'm coming unstuck! I have an external style sheet linked to by all pages with basic styles for links (including hover, visited, active) text, etc have also sussed out classes for other bits to look different but my problem is having classes for a seperate set of links to look different?

So basically I have the main links say green with no underline going to red on hover with an underline & then I want one specific link to be purple no underline & orange with no underline on hover. How do I set up the class to handle all the link states?

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Julia,

Css isn't my forte. But...

you should be able to do something like:

#purple {
...preferred styles go here...
}

detox's picture

They have: 571 posts

Joined: Feb 2001

I have always used this to differentiate between styles for hover:

<?php
a
:link { color: #000000; text-decoration:none; }
a:visited { color: #000000;  text-decoration:none;}
a:active { color: #000000; text-decoration:none;}
a:hover { color: #99CC01; text-decoration:underline;}
a:link.orange { color: #FF9900; text-decoration:none; }
a:visited.orange { color: #FF9900;  text-decoration:none;}
a:active.orange{ color: #FF9900; text-decoration:none;}
a:hover.orange { color: #666666; text-decoration:none;}
?>

simply add .classname to a copy of your original link values

so a:link becomes a:link.orange etc

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

so I would just put class="orange" within the link tag then?

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

That didn't work, well sort of did - changed the colour of the link but not the hover part! Here's my style sheet any way :

table { font-family: Verdana; font-size: 12px; color: #000066}
a { color: #6666CC; text-decoration: none}
a:active { color: #000066; text-decoration: underline}
a:hover { color: #99CCCC; text-decoration: underline}
li { list-style-image: url(1bullet.gif)}
.headers { font-family: Verdana; font-size: 12px; font-weight: bold; color: #FFFFFF}
a.bottom { font-size: 10px; font-weight: bold; color: #99CCCC; text-decoration: none}
a:active.bottom { color: #000066; text-decoration: underline}
a:hover.botton {color: #6666CC; text-decoration: underline}

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

detox's picture

They have: 571 posts

Joined: Feb 2001

yep....

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

With this style sheet it's now just changing it so the links are green all the time!

Brooke's picture

She has: 681 posts

Joined: Feb 1999

this is how I did it:

Then the ref tags you put this:

or type2 or type3 - whatever it corresponds to.

Brooke

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

sorted it by doing this:

table { font-family: Verdana; font-size: 12px; color: #000066}
a { font-weight: bold;color: #6666CC; text-decoration: none}
a:active { color: #000066; text-decoration: underline}
a:hover { color: #99CCCC; text-decoration: underline}
li { list-style-image: url(1bullet.gif)}
.headers { font-weight: bold; color: #FFFFFF}
.bottom { font-size: 9px; font-weight: bold; color: #99CCCC}
.bottom a { color: #99CCCC; text-decoration: none}
.bottom a:active { color: #000066; text-decoration: underline}
.bottom a:hover {color: #6666CC; text-decoration: underline}

found a good tutorial here and they do them specifically for use with DW but good anyway if you don't use it.

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Hmmm... interesting... three different ways to do it here:

.bottom a:hover
a.bottom:hover
a:hover.bottom

Which is the correct way? Or does it matter? I use the second method.

Quote: That didn't work, well sort of did - changed the colour of the link but not the hover part! Here's my style sheet any way :

table { font-family: Verdana; font-size: 12px; color: #000066}
a { color: #6666CC; text-decoration: none}
a:active { color: #000066; text-decoration: underline}
a:hover { color: #99CCCC; text-decoration: underline}
li { list-style-image: url(1bullet.gif)}
.headers { font-family: Verdana; font-size: 12px; font-weight: bold; color: #FFFFFF}
a.bottom { font-size: 10px; font-weight: bold; color: #99CCCC; text-decoration: none}
a:active.bottom { color: #000066; text-decoration: underline}
a:hover.botton {color: #6666CC; text-decoration: underline}

When in doubt, check your spelling Smiling

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Yeah I did actualy realise I had spelt the bottom bottom wrong but at that point it still was working even when I changed it!!

Thanks for all your help Laughing out loud

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

According to proper CSS via here , the proper anchor pseudo-class would be:

<?php
A
.external:visited { color: blue }

  <
A CLASS=external HREF=\"http://out.side/\">external link</A>
?>

Now I suspect that some of the other variations would work but not cross browser. I generally do mine like so:

<?php
.nav     {
   
text-decoration:none;
   
font-weight: 900;
   
font-size : 10px;
   
color:#000099;
   
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    }
.
nav:active {
   
text-decoration:none;
   
font-weight: 900;
   
font-size : 10px;
   
color:#000099;
   
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    }
.
nav:link {
   
text-decoration:none;
   
font-weight: 900;
   
color:#000099;
   
font-size: 10px;
   
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    }
.
nav:visited {
   
text-decoration:none;
   
font-weight: 900;
   
color:#000099;
   
font-size: 10px;
   
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    }                
.
nav:hover {
   
text-decoration:none;
   
font-weight: 900;
   
color:#990000;
   
font-size : 10px;
   
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
        }
?>

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

You all go and discuss some of my favourite topics!

The first two methods that Mark and Megan demonstrated work cross-browser, the but the explicit a.class:pseudoclass is preferred because of inheritance issues with Netscape 4.x.

.class a:pseudoclass requires that the browser understand parent/child distinctions and it's better safe than sorry with Netscape 4.x... Wink

I think this question (how to have links different in different places on the page) is THE most asked question for CSS.

Smiling Suzanne

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Suzanne, I knew that you would have to get in on this. Seeing as how you are the Queen of CSS.

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Ok, next question!

I want to have the following in a cell of a table which has the text set via css to be blue, veranda, 12pixels.

link (underlined all the time & bold)
text description (normal text as per css above)
link (not underlined & not bold)

How can I accomplish this using css? I'm getting very tied up in knots trying to get my head around this one!

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

link (underlined all the time & bold)

.bu {
font-weight: bold;
text-decoration: underline;
}

text description (normal text as per css above)

add td to your list of items:

p, td {
color: blue;
font-family: verdana, geneva, sans-serif;
font-size: 12px;
}

link (not underlined & not bold)

.nochange {
font-weight: normal;
text-decoration: none;
}

bold underlined link and some regular text and another link.

Smiling Suzanne

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

What characters are valid for class and id names?

I think I ran into a problem using the underscore (or maybe it was the dash)... So I try to stick to alpha characters.

Mark Hensler
If there is no answer on Google, then there is no question.

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Thanks Suzanne, I might get it all straight in my head one of these days!!

mmi's picture

They have: 457 posts

Joined: Jan 2001

hey Mark - from downtown

Quote: * In CSS2, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [A-Za-z0-9] and ISO 10646 characters 161 and higher, plus the hyphen (-); they cannot start with a hyphen or a digit. They can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".

Note that Unicode is code-by-code equivalent to ISO 10646 (see [UNICODE] and [ISO10646]).

from the blooberry patch

Quote: * Netscape 4.x and Opera 3.5+ do not allow CLASS or ID attributes to contain underscore characters ("_".) Underscores are legal in HTML atributes according to the HTML standards but not according to the CSS standard.


Web Xpertz Community Forums for Webmasters & Developers

Where You Can Learn, Advise, and Have Fun in the Process

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.