Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,883 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,046 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Anchor pseudo-classes in CSS (glowing hyperlinks)

 
Reply to this topicStart new topic

> Anchor pseudo-classes in CSS (glowing hyperlinks)

polymath
Group Icon



post 5 Apr, 2008 - 02:01 PM
Post #1


Ok, before you begin, you should have some basic understanding of CSS.

Now, have you ever seen a website where the hyperlinks grow when you mouse over them, or underline themselves? The code behind these hyperlinks is relatively easy, yet if used correctly, can make you site look more professional.

First, you need to know about pseudo-classes. The syntax for these in CSS is:
selector.class:pseudo-class {attribute}
In otherwords, CSS defines a number of classes relative to the user or the surrounding code which it can use to apply to a class of a certian selector.

The most unique are the anchor (hyperlink) pseudo classes. These have special effects when they are clicked or moused over. The default color and the "clicked" color of hyperlinks is determined by the surrounding font color, but now you are not limited by this. Take the following code:
CODE
/* colors will be: */

/* normal link- yellow */
/* visited link- cyan */
/* mouse over link- firebrick */
/* selected link- lawn green */

a.one:link {color: yellow}
a.one:visited {color: #00FFFF}
a.one:hover {color: #B22222}
a.one:active {color: #7CFC00}


This code defines the different colors of all hyperlinks with the class attribute of "one" to have certian colors, while not affecting those which don't have both the pseudo-class and the normal class. For example <a href="#">unaffected</a> would be unaffected but <a href="#" class="one">affected</a> would be affected by the css class.

Now for the fun part...

The hover pseudo-class can be used to create special effects beyond coloration. Take (for example) the following Style Sheet:
CODE
a.grow:link {color: #ff0000}
a.grow:visited {color: #0000ff}
a.grow:hover {font-size: 150%}

a.highlight:link {color: #ff0000}
a.highlight:visited {color: #0000ff}
a.highlight:hover {background: #66ff66}

a.chngfont:link {color: #ff0000}
a.chngfont:visited {color: #0000ff}
a.chngfont:hover {font-family: monospace}

a.underline:link {color: #ff0000; text-decoration: none}
a.underline:visited {color: #0000ff; text-decoration: none}
a.underline:hover {text-decoration: underline}

All of these link classes each have their own action when they are moused over. You can also put most other identifiers next to the a:hover line. Thats pretty much it for anchor pseudoclasses. Hopefully, more tutorials to come!

Thats all folks! cool.gif

This post has been edited by polymath: 11 Apr, 2008 - 10:46 AM
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 10/13/08 03:01AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month