# xsl:if

The `xsl:if` element is used for conditional processing. It takes a mandatory `test` attribute, whose value is a boolean expression. The contents of the xsl:if element are expanded only of the expression is true.

The full syntax of boolean expressions is outlined in XPath Expression Syntax.

Example:

    <xsl:if test="@preface">
            <a href="preface.html">Preface</a>
    </xsl:if>

This includes a hyperlink in the output only if the current element has a `preface` attribute.

Next