• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<a href="backuplink.html" class="doSomething">Click!</a>

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


Thanks in advance.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class is a CSS Class

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


Eric
 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic