Classes in links?

  • Bogey
  • Ounce of 'Zu'
  • Web Master
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 4221
  • Loc: Ozzu
  • Status: Offline

Post May 3rd, 2008, 10:07 pm

Is it possible to have classes in links?
  1. <a class="class1" href="link.php">Link</a>

If so, why doesn't it work for me?

Here is the HTML (PHP) that I'm using...
  1. <a href="mail.php?mode=read&amp;post='. $id .'" class="mail">'. substr($subject, 0, 20) .'...</a>

And here is the CSS for it.
  1. .mail a {
  2.   display: block;
  3.   float: left;
  4.   text-decoration: none;
  5.   width: 175px;
  6.   color: #005500;
  7. }
  8.  
  9. .mail a:hover {
  10.   display: block;
  11.   float: left;
  12.   width: 175px;
  13.   color: #002200;
  14. }

Any help would be great :D
01000010 01101111 01100111 01100101 01111001
My Developing Blog (5)
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 3rd, 2008, 10:07 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: 20 Dec 2002
  • Posts: 6110
  • Loc: Seattle, WA
  • Status: Offline

Post May 5th, 2008, 10:54 am

Your CSS is wrong. According to your CSS it would work for a tag with the mail class that has a tag inside it with the 'a' tag. So for instance This would be valid for your CSS:

  1. <div class="mail"><a href="blah.html">link</a></div>


If you want to actually use the CSS the way you have the html with the class on the 'a' tag itself you would change your CSS to:

  1. a.mail {
  2.   display: block;
  3.   float: left;
  4.   text-decoration: none;
  5.   width: 175px;
  6.   color: #005500;
  7. }
  8.  
  9. a.mail:hover {
  10.   display: block;
  11.   float: left;
  12.   width: 175px;
  13.   color: #002200;
  14. }


Hope that helps.
Webmaster Resources
UNFLUX.net - Quality Web Hosting
  • Bogey
  • Ounce of 'Zu'
  • Web Master
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 4221
  • Loc: Ozzu
  • Status: Offline

Post May 5th, 2008, 7:34 pm

It did. Thanks so much. I got much to learn :)

Thanks bigweb. I appreciate it a lot.
01000010 01101111 01100111 01100101 01111001
My Developing Blog (5)

Post May 7th, 2008, 2:27 am

if you want to do it with something like:
  1. <a class='something'></a>

then your css would be:
  1. a.something{bla bla}
  2. a.something:hover{bla bla}
DAIRY!

Post Information

  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates


400+ FREE Website Templates. Download Now!