CSS Question

What is the difference between class and styleClass attributes?

I use PrimeFaces component but I don't understand difference between styleClass and class. I can use both of them and I don't see any difference. What is the difference between class and styleClass attributes in PrimeFaces?

Answer Source

In fact in JSF and Primefaces:

  • styleClass is used to specify classes to JSF components, it will be then converted to a class attribute in the rendered HTML code.
  • And class attribute is used with HTML elements, and can't be used directly with JSF components.

And when you open any JSF tag documentation, you will see that:


The styleClass attribute sets the CSS class to apply to this component when it is rendered.

You can see JSF h:outputText tag for example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download