Posts tagged ‘Pseudo-classes’

August 12, 2008

CSS: Pseudo-Classes for Link Styles

I wanted a Navigation Bar on my web page, but I didn’t want the links to look different, ie, different colours for visited and unvisited links, or underlined. I only knew how to do this by defining it within the <body> tag, like so:

<body link=”red” vlink=”blue”>

</body>

Clearly this is not ideal, for a couple of reasons:

1.  I want the Navigation Bar to be a specific colour, which may, or may not be, the same as the rest of the web page
2.  I may want other link(s) within the page to be a different colour(s)
3.  I’m still currently experimenting with styles and will most likely change my mind later on. It would be easier if I only have to make my changes in one place.

Stylesheets is the way to go. However, it took hours of frustration and an “I’ve looked everywhere else” before I decided to click on “CSS Pseudo-classes” – which I kept overlooking because I didn’t think it was relevant (w3schools.com/css).

CSS pseudo-classes are used to add special effects to some selectors.

Syntax:

selector:pseudo-class {property: value}

or, used with classes

selector.class:pseudo-class {property: value}

My example:

a.menu:visited, a.menu:link
{
color: wheat;
font-style: normal;      
text-decoration: none;   <!– No underline –>
}

<a class=”menu” href=learning_proposal.htm>learning proposal</a>

<a class=”menu” href=links.htm>links</a>

Hooray it worked! Refer to My Webpage – http://dmtsar.0fees.net

Reference

1. http://w3schools.com/css

Follow

Get every new post delivered to your Inbox.