Classes in links?

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Is it possible to have classes in links?
Code: [ Select ]
<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...
Code: [ Select ]
<a href="mail.php?mode=read&amp;post='. $id .'" class="mail">'. substr($subject, 0, 20) .'...</a>

And here is the CSS for it.
CSS Code: [ Select ]
.mail a {
 display: block;
 float: left;
 text-decoration: none;
 width: 175px;
 color: #005500;
}
 
.mail a:hover {
 display: block;
 float: left;
 width: 175px;
 color: #002200;
}
  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
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9086
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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:

Code: [ Select ]
<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:

Code: [ Select ]
a.mail {
  display: block;
  float: left;
  text-decoration: none;
  width: 175px;
  color: #005500;
}
 
a.mail:hover {
  display: block;
  float: left;
  width: 175px;
  color: #002200;
}
  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.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

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

Thanks bigweb. I appreciate it a lot.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

if you want to do it with something like:
HTML Code: [ Select ]
<a class='something'></a>

then your css would be:
CSS Code: [ Select ]
a.something{bla bla}
a.something:hover{bla bla}
  1. a.something{bla bla}
  2. a.something:hover{bla bla}

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 69 guests
  • 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.