merve karakarçayıldız merve karakarçayıldız - 3 months ago 17
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

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:

styleClass

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.

Comments