What is the difference between class and styleClass attributes in JSF?

east825 picture east825 · Jan 2, 2014 · Viewed 26.7k times · Source

I see, that in JSF most of the standard components that mapped to HTML tags, e.g. <h:commandButton/>, have attributes class and styleClass. But no matter, which one I use, both is rendered as class attributes in markup.

So why there are two attributes with the same purpose?

Answer

Alexandre Lavoie picture Alexandre Lavoie · Jan 2, 2014

There is simply no class attribute in JSF components.

From the doc, attribute styleClass :

Space-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup.

The styleClass is simply converted as class in the rendered HTML.

More info :