custom.css.source — Name of a custom CSS input file


<xsl:param name="custom.css.source"></xsl:param>


The custom.css.source parameter enables you to add CSS styles to DocBook's HTML output.

The parameter specifies the name of a file containing custom CSS styles. The file must be a well-formed XML file that consists of a single style root element that contains CSS styles as its text content. For example:

<?xml version="1.0"?>
h2 {
  font-weight: bold;
  color: blue;

The filename specified by the parameter should have a .xml filename suffix, although that is not required. The default value of this parameter is blank.

If custom.css.source is not blank, then the stylesheet takes the following actions. These actions take place regardless of the value of the make.clean.html parameter.

  1. The stylesheet uses the XSLT document() function to open the file specified by the parameter and load it into a variable.

  2. The stylesheet forms an output pathname consisting of the value of the base.dir parameter (if it is set) and the value of custom.css.source, with the .xml suffix stripped off.

  3. The stylesheet removes the style wrapper element and writes just the CSS text content to the output file.

  4. The stylesheet adds a link element to the HTML HEAD element to reference this external CSS stylesheet. For example:

    <link rel="stylesheet" href="custom.css" type="text/css">

If the make.clean.html parameter is nonzero (the default is zero), and if the docbook.css.source parameter is not blank (the default is not blank), then the stylesheet will also generate a default CSS file and add a link tag to reference it. The link to the custom CSS comes after the link to the default, so it should cascade properly in most browsers. If you do not want two link tags, and instead want your custom CSS to import the default generated CSS file, then do the following:

  1. Add a line like the following to your custom CSS source file:

    @import url("docbook.css")
  2. Set the parameter to zero. This will omit the link tag that references the default CSS file.

If you set make.clean.html to nonzero but you do not want the default CSS generated, then also set the docbook.css.source parameter to blank. Then no default CSS will be generated, and so all CSS styles must come from your custom CSS file.

You can use the generate.css.header parameter to instead write the CSS to each HTML HEAD element in a style tag instead of an external CSS file.