#### 31.8.3 Overriding styles in DITA2Go-generated CSS files

When you direct DITA2Go to generate a CSS file anew each time (that is, when [CSS]WriteCssStylesheet=Always), styles are updated from the formats in your document, and anything you added directly to the CSS file is lost. However, you can include settings in the configuration file to modify the generated CSS file. With these settings you can do any or all of the following:

Override CSS code | Replace generated CSS code with fixed CSS code for selected formats.
Omit CSS code | Prevent CSS code from being written to the CSS file for selected formats.
Add CSS code | Add code to the beginning or the end of the generated CSS file.

See also:

§31.8.1 Specifying CSS <body> tag properties

§31.8.2 Specifying CSS size values and units of measurement

Override CSS code

To override the style specification in a DITA2Go-generated CSS file for a particular format, assign a property to the format, and optionally provide replacement code for the style. For example:

    [HTMLParaStyles] or [HTMLCharStyles]
    ; CSSReplace uses [ParaStyleCSS] or [CharStyleCSS] to specify
    ; on a single line the code to be written to the .css for the
    ; format when [HtmlOptions]WriteCssStylesheet = Always or Once
    ; NoCSS suppresses writing info to the .css file for its format.
    SomeFmt = CSSReplace
    OtherFmt = NoCSS

When you assign property CSSReplace to a format, you must also specify replacement CSS code for that format in section [ParaStyleCSS]for a paragraph format or [CharStyleCSS] for a character format. The code assignment must be all on one line. For example:

    [ParaStyleCSS]
    SomeFmt = p.somefmt {font: bold 12pt/14pt sans-serif}

Omit CSS code

When you assign property NoCSS to a format, DITA2Go still generates the class attributes in the HTML, but does not include them in the CSS file.

Add CSS code

To add starting and ending code to a generated CSS file:

    [CSSStartMacro]
    ; CSS code to be inserted at the start of the .css file if generated

    [CSSEndMacro]
    ; CSS code to be inserted at the end of the .css file if generated

You can use these macro configuration sections to add more CSS entries, perhaps with selectors DITA2Go does not use; or add CSS code for positioning, or to set anchor properties, or <body> properties, or special properties for nested items.

Previous Topic: 31.8.2 Specifying CSS size values and units of measurement

Next Topic: 31.8.4 Adjusting leading (line spacing) in CSS

Parent Topic: 31.8 Customizing CSS properties

Sibling Topics:

31.8.1 Specifying CSS <body> tag properties

31.8.2 Specifying CSS size values and units of measurement

31.8.4 Adjusting leading (line spacing) in CSS

31.8.5 Preventing <font> tags from overriding CSS properties

Table of Contents • Index