2

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?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • so you are saying that `` and `` both with the same css class definition result in te same look and feel in the browser? – Kukeltje Aug 19 '16 at 09:58
  • Does this only happen with PrimeFaces components or also plain jsf? See http://stackoverflow.com/questions/20884950/what-is-the-difference-between-class-and-styleclass-attributes-in-jsf. And please state version info of both PF and jsf (including implementation) and post an [mcve] – Kukeltje Aug 19 '16 at 10:17

1 Answers1

3

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.

cнŝdk
  • 31,391
  • 7
  • 56
  • 78
  • your answer is a duplicate of http://stackoverflow.com/questions/20884950/what-is-the-difference-between-class-and-styleclass-attributes-in-jsf. But It **seems** (not sure, therefor I requested confirmation) the OP says that a class attribute **is** usable on PF components – Kukeltje Aug 19 '16 at 10:36
  • @Kukeltje No in fact the other answer only define the `styleClass`property, and here I am explaining the use of each property and the tags that accepts it, It's similar yes but it's more detailed here. – cнŝdk Aug 19 '16 at 10:43
  • If you say so... To me this answer and the other one are identical. – Kukeltje Aug 19 '16 at 10:45
  • That's you point of vue ;). It only includes **JSF** here beacuse **Primefaces** is built on JSF. – cнŝdk Aug 19 '16 at 10:48