Next: , Previous: XSLT parameters, Up: Configurability



4.2 CSS style sheets

With the XSLT parameter css-file you can give the file name of a special XML file with the following example contents:

<style xmlns="http://www.w3.org/1998/Style/CSS2">
  h1 { color: red }
</style>

This would print all first-level headings red. The <style> tags must look exactly like this, other XML tags are not allowed. Between them you may insert arbitrary CSS (“Cascading Style Sheets”) commands. They are loaded last and thus have priority. You can change the final layout of your (X)HTML document in many ways. Other output formats are not affected.

Let's have a look at another, more complete example. You want to change all colours in your HTML file. This black on white is boring and too bright for you. Therefore you create a file called mybook-css.xml with the following contents:

<style xmlns="http://www.w3.org/1998/Style/CSS2">
    body { background-image: url("blue-tile.png");
           background-color: navy;
           color: white }
    hr.footnoterule { color: white }
    div.title { font-size: x-large; color: yellow }
    div.title-article { font-size: x-large }
    div.partheadline { font-size: x-large }
</style>

This sets a navy blue background, and the PNG bitmap blue-tile.png as the background pattern. (You are responsible that this PNG file exists.) The text colour is now white. Additionally, all parts of the output that used to be `xx-large' are now only `x-large' because Internet Explorer tends to print them too big. This affects the title (both book and article) and the parts headings.

For more info about the CSS please consult the W3C specification page, and you will find nice books about them in your favourite library/bookstore.

The default CSS commands for tbook documents can be found in tbookxsl.pdf which is produced with

make tbookxsl.pdf

in section 2.2.5, “CSS style sheets”. But even easier is to have a look at the beginning of an HTML file that tbook produces where you find the whole tbook CSS code. And then you can overwrite the things that you don't like with your own code.