Pseudo classes


I think that the default hyperlinks and forms are pretty boring, so time to spice them up. =D

First open up a new html document.

Add the following inbetween <head></head> CSS:
CSS Code
  1. <style>
  2. a {font-family:Arial, Helvetica, sans-serif; color:#FF0000; text-decoration:none;}
  3. a:hover {color:#0000CC;}
  4. </style>


or link it to an external css page.
HTML inbetween <body></body>:
CSS Code
  1. <a href="#">Home</a>



This will now change Home to Home when you scroll over it.

Note this will do this to all hyperlinks. To do this to seperate ones use: CSS:
CSS Code
  1. .linkname {}
  2. .linkname:hover {}


HTML:
CSS Code
  1. <a class="linkname" href="#">Home</a>


------------------

It's pretty much the same with forms.

CSS:

CSS Code
  1. <style>
  2. .formname {font-family:Arial, Helvetica, sans-serif; color:#FF0000; text-decoration:none; background:#999999; border:1px #333333 solid;}
  3. .formname:hover {color:#0000CC; background:#000000; border:1px #ff0000 solid;}
  4. </style>


HTML:

CSS Code
  1. <form action="" method="">
  2. Username: <input type="text" class="formname" name="user" maxlength="30" value="">
  3. Password: <input type="password" class="formname" name="pass" maxlength="30" value="" />
  4. <input type="submit" class="formname" value="Login">
  5. </form>


That is for seperate forms because its using classes but if you want to do all of them replace .formname with input.

Results:

TutorialNinja Image

to

TutorialNinja Image

----------

Obviously the colors dont go but i was using them as an example.
JakkyD's Avatar
Author:
Views:
2,115
Rating:
Posted on Sunday 4th May 2008 at 05:07 PM
jambomb
jambomb's Avatar
aa thats awsum :)