Help:Infoboxes/CSS

Portable infoboxes can be themed quite simply using custom CSS.

Infobox themes
Default infobox theming can be overwritten using either theme or theme-source attributes of the infobox tag, allowing infoboxes to be styled via local community CSS. See to learn more about styling. If both attributes are used inside the infobox tag, the theme attribute is treated as the default. Note that spaces in the values of theme and theme-source are converted to hyphen-minuses, so only a single class may be added using them.
 * The theme attribute is used to specify a custom CSS class for the infobox.
 * The theme-source attribute allows you to vary the CSS class via a template parameter.

"Theme"
For example, theme="delta" will add a class called portable-infobox-theme-delta to the infobox HTML, which can then be customized using CSS:

// infobox contents go here

The code below could then be used to change the background to red:

"Theme-source"
For example, theme-source="location" means that, when location is specified in an article's infobox, it will use the value of it as the class.

For example:  ...

The CSS to theme the template will thus be:

If you want to target specific elements within that infobox, you would do then something like this:

Helper classes
Portable infoboxes contain a couple of helper classes to help you easily update the styling of various basic aspects:
 * : overall infobox background
 * : header and navigation backgrounds
 * : data value font styling
 * : header, label and navigation font styles
 * : paddings around each infobox element
 * : infobox element border colors

Sample code snippets
Create custom theme "oblivion" and tweak caption font size:

Change infobox width:

Change infobox background color:

Change infobox headers and navigation background:

Change infobox elements border color:

Change infobox elements paddings:

Change infobox data values font size:

Change infobox headers, labels and navigation values font size:

Change infobox title font size:

Advanced
When a CSS class is on the same element as another, and you need to select for both, leave no space between the classes. For example,  is on the same   element as the theme, so CSS that changes the background for that theme would be: