Extension:TemplateStyles

The TemplateStyles extension introduces a  tag to supply a cascading stylesheet fragment in templates that, when transcluded, are added to the page CSS.

By default, only transclusions of pages within the Template: namespace will allow style sheets; but the extension can be configured to allow it for other namespaces.

Use
The TemplateStyles extension works through having a  tag defined in the wikitext of a template page (optionally it can be transcluded from a different page as well). This is designed to be compatible with the common layout many wikis have of transcluding template documentation from a separate page (but is not required). This content of the  tag is a style sheet fragment containing style rules, or   at-rules.

When a page is rendered, the union of the style sheets attached to all of the templates transcluded on it is added to the header of the HTML document. This makes the styles avaliable to the template expansions (and the rest of the page).

Unlike global style sheets (such as Common.css), the template's styles are inlined in the HTML document proper and are therefore not cached independently of the page itself.