Using Custom CSS Style Sheets

You can include custom CSS styles sheets in your EPUB just as you can for HTML output generally.

The EPUB transformation type uses the same Ant parameters for CSS styles sheets as for the normal HTML transformation type. The difference is that you must copy the CSS files to the output since they need to be part of the EPUB package. Thus the args.copycss parameter is implicitly set to "yes" if you specify the args.css parameter.

Likewise, the parameter args.csspath is ignored because the EPUB processor controls how the CSS files are referenced in the generated HTML files.

You may specify the directory within the EPUB package to contain the CSS files using the parameter args.css.output.dir. By default it is the same as the topic output directory (which by default is "topics").

The args.css parameter can be an absolute path to the CSS file or it can be a path relative to the value of the args.cssroot parameter.

For example, if you have a custom CSS file mystyle.css in the directory c:\projects\mydoc\css and you want to use that CSS file in your EPUB you would specify the Ant parameter args.css with the value "c:\projects\mydoc\css\mystyle.css".

If you have a common CSS source directory and you use different CSS files for different publications, you can specify both args.cssroot and args.css like so:
  • args.cssroot as "c:\projects\mydoc\css"
  • args.css as "mystyle.css"

If you want your CSS somewhere other than the topics directory, specify the css.output.dir parameter to the desired directory name, e.g. "css".

The built-in CSS style sheets provided with the DITA Open Toolkit are always included in the EPUB in the CSS output directory and are always referenced in the HTML after any user-specified CSS style sheet.