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?
StyleClass manages css classes declaratively to during enter/leave animations or just to toggle classes on an element.
So the difference between both is you can re-use classes whereas you can't re-use inline styles. Save this answer.
To define multiple classes, separate the class names with a space, e.g. <div class="city main">. The element will be styled according to all the classes specified.
The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!
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 :
See this references:
http://www.roseindia.net/jsf/commandButton.shtml
http://www.developersbook.com/jsf/jsf-tags-reference/html/commandButton.php
style: If you want ot add any CSS with the component then you can put the style as the value of the attribute. Added CSS will be applied on for the component.
styleClass: This attribute holds the CSS class name which is defined in the external style sheet.
The attribute style in JSF is equivalent to attribute style in HTML.
The attribute styleClass in JSF is equivalent to attribute class in HTML.
Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With