aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes what is the use of class attribute associated with a HTML element. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "what is the use of class attribute associated with a HTML element." Watch "what is the use of class attribute associated with a HTML element." New topic
Author

what is the use of class attribute associated with a HTML element.

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
<a href="backuplink.html" class="doSomething">Click!</a>

why class is being used here instead of directly using onclick ??


Thanks in advance.


If you want something you never had do something which you had never done
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
class is a CSS Class

Read about it here:http://www.w3schools.com/css/css_syntax.asp


Eric
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
You would use "class" to refer back a predefined CSS style. You can leave it out and the default or global styles will take place or you can specify a class and have those styles applied. This is great when you have multiple styles for one type of element and you want them to have different styles from each other.

Consider this CSS style:



Now, let's say you have a hyperlink on your website. Any hyperlinks you want to be red you would do this:



And any hyperlink you wanted blue you would do this:



You can do this with just about any element, not just anchor tags.

HTH GL


SCJA
~Currently preparing for SCJP6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the use of class attribute associated with a HTML element.