I would recommend using:
.ui-widget {
font-size: 90%;
}
.ui-widget .ui-widget {
font-size: 100%;
}
instead of BalusC's approach, unless you like the font size decreasing as you nest your JSF components together.
I'd agree with BalusC that you should create a stylesheet and consider templating, but I disagree with the suggested CSS (though I'm still not decided on the use of !important
!).
Section 8.4 of the Primefaces 3.1 user guide suggests using
.ui-widget, .ui-widget .ui-widget {
font-size: 90% !important;
}
which is similar to BalusC's suggestion but uses !important
.
This will do two things:
- set the font size of components with the
ui-widget
class to 90%
(of the parent)
- set the font size of components with the
ui-widget
class and are children of another component with the ui-widget
class to 90% (of the parent)
Do you really want to set the font size of a nested ui-widget
to 90%? If you have 2 or 3 levels of nested ui-widget
s the font size is going to keep decreasing. Try the following (Primefaces) JSF markup and you'll see my point.
<h:form>
<p:button value="Normal"></p:button>
<p:panel>
<p:button value="A bit smaller"></p:button>
<p:panel>
<p:button value="Even smaller again"></p:button>
<p:panel>
<p:button value="Tiny"></p:button>
</p:panel>
</p:panel>
</p:panel>
</h:form>
I believe the reason .ui-widget .ui-widget
was required in the standard jQuery CSS was to prevent the reverse problem: font size increasing in nested ui-widget
s.
The default styles are typically the following:
.ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
.ui-widget .ui-widget { font-size: 1em; }
Without the style defined for .ui-widget .ui-widget
, the default font-size: 1.1em
style applied to .ui-widget
causes the font size to increase in nested ui-widget
s.
By adding the more specific .ui-widget .ui-widget
selector with font size set to 100% (or 1em) you will ensure that you get a consistent font size, no matter how deep you nest your components.