Css

On this page:

Syntax

<txp:css />

The basic css tag is a single tag used to output the URL of the stylesheet assigned in the Textpattern Sections administration panel.

Attributes

Tag will accept the following attributes (case-sensitive):

format="value"
How to format output: either return complete HTML link tag with necessary HTML attributes, or only the stylesheet’s URL.
Values: link or url.
Default: url.
media="value"
HTML media attribute to be applied to link tag (when invoked with format="link").
Default: screen.
name="style name"
Link to specified style.
rel="value"
HTML rel attribute to be applied to link tag (when invoked with format="link").
Default: stylesheet.
title="value"
HTML title attribute to be applied to link tag (when invoked with format="link").
Default: unset.

Examples

Example 1: Output just the stylesheet’s URL

<head>
    <!-- ...tags... -->
    <link rel="stylesheet" href="<txp:css />" media="screen, projector">
    <!-- ...more tags... -->
</head>
<head>
    <!-- ...tags... -->
    <txp:css format="link" />
    <!-- ...more tags... -->
</head>
<head>
    <!-- ...tags... -->
    <txp:css format="link" name="style_name" />
    <!-- ...more tags... -->
</head>

Example 4: Output print and alternate stylesheets

<head>
    <!-- ...tags... -->
    <txp:css format="link" name="plain" rel="alternate" title="Plain and simple style" />
    <txp:css format="link" name="glossy" rel="alternate" title="Glossy style" />
    <txp:css format="link" name="print" media="print" />
    <!-- ...more tags... -->
</head>

Genealogy

Version 4.3.0

n attribute deprecated and renamed to name.

Version 4.0.4

format, media, rel and title attributes added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please write an issue and we’ll fix it.