#### 31.6.2 Changing CSS files in the middle of a document

To have DITA2Go reference different style sheets for output from different parts of your DITA document, you can use a macro to provide the CSS link, then insert PI markers in your document to signal a change of CSS file. To prevent DITA2Go from automatically generating a CSS file reference, you must also specify:

    [CSS]
    WriteCssLink=No

To generate a CSS file reference from your document, assign a macro to be placed in the <head> element of each HTML output file; for example:

    [Inserts]
    Head=<$CSSmacro>

Include in the macro definition a macro variable (for example, $$myAltCSS) in place of the base name of the CSS file:

    [CSSmacro]
    ; You must type the following all on one line:
    <link rel='stylesheet' href='<$$myAltCSS>.css' charset=ISO-8859-1 type='text/css' />

Give the macro variable an initial value: the base name of the first CSS file you want referenced:

    [MacroVariables]
    myAltCSS=UsualCSS

DITA2Go uses the value of macro variable $$myAltCSS to select a CSS file at the start of each file split.

To change $$myAltCSS to a different value for a subsequent split, you must place a PI marker in a paragraph before the split. You can use a HTML Macro PI marker, with content as follows:

    <$$myAltCSS=OtherCSS>

To assemble the macro around the CSS file value, also specify the following:

    [MarkerTypes]
    CSSname=Code

    [MarkerTypeCodeBefore]
    CSSname=<$$myAltCSS=

    [MarkerTypeCodeAfter]
    CSSname= >

To change the value of $$myAltCSS for a particular file in your document, place in the project directory a file-specific configuration file that contains (only) the following setting:

    [MacroVariables]
    myAltCSS=SpecialCSS

See §42.1 Using a different configuration for selected files.

Previous Topic: 31.6.1 Selecting a CSS file at run time

Next Topic: 31.6.3 Customizing the CSS link tag

Parent Topic: 31.6 Linking to alternate CSS files

Sibling Topics:

31.6.1 Selecting a CSS file at run time

31.6.3 Customizing the CSS link tag

31.6.4 Using an alternate CSS link tag for Netscape 4