#### 31.7.1 Understanding CSS class name restrictions

Use only letters and numbers in class names

Class names used with CSS may contain alphanumeric characters only. You cannot use spaces or symbols; not even underscores. Class names in HTML output must match in case the same names in the CSS file. DITA2Go imposes an internal limit of 128 characters on CSS class names.

To create class names from format names, DITA2Go does the following:

- removes or replaces spaces
- removes all non-alphanumeric characters
- replaces accented characters with their non-accented equivalents
- for output types that require lowercase CSS, changes all characters to lowercase, regardless of whether format names are uppercase, lowercase, or mixed case.

These transformations might lead to conflicts if your format names differ only in spacing, in case, or by any removed characters.

Replace spaces with a character

You can specify a letter, a number, an underscore, or a hyphen to substitute for spaces in class names. For example:

    [HtmlOptions]
    ; These alphanumeric chars are used as space replacements in IDs;
    ; if non-alphanumeric (other than hyphen or underscore), spaces are
    ; stripped instead (default)
    ; ClassSpaceChar = char to use as space replacement
    ClassSpaceChar = _

Remove spaces

By default, DITA2Go removes spaces without replacing them. The same thing happens if you set ClassSpaceChar to any non-alphanumeric character other than a hyphen or an underscore: DITA2Go removes all spaces without replacing them.

Case of class names

CSS does not distinguish between names that differ only in case; if you use both heading1 and Heading1, and they are defined differently, you are sure to see some unexpected results. Class names in HTML files must match in case the corresponding names in the CSS file. Class names can be mixed case for some output types, but must be lowercase for other output types:

- For XML, XHTML, JavaHelp, and Oracle Help, DITA2Go changes all generated class names in output in lowercase.
- For standard HTML, HTML Help, and OmniHelp, class names generated from formats retain their original case.

You can force lowercase class names for any HTML output type. To make generated class names all lowercase:

    [CSS]
    ; LowerCaseCSS = No (default mixed case)
    ;  or Yes (lower case only, JH, OHJ, XML, and XHTML)
    LowerCaseCSS = Yes

Previous Topic: 31.7 Assigning CSS classes

Next Topic: 31.7.2 Mapping paragraph formats to CSS classes

Parent Topic: 31.7 Assigning CSS classes

Sibling Topics:

31.7.2 Mapping paragraph formats to CSS classes

31.7.3 Mapping character formats to tags or span classes

31.7.4 Assigning CSS classes to table formats

31.7.5 Assigning CSS classes to text and table footnotes

31.7.6 Assigning CSS classes based on Unicode character ranges

31.7.7 Using link format names as CSS class names

31.7.8 Using CSS class names as tags for XML

31.7.9 Omitting tags from CSS selectors

31.7.10 Overriding CSS class for selected paragraphs

Table of Contents • Index