31.7.3 Mapping character formats to tags or span classes

When you use CSS, DITA2Go generates any tags assigned to a character format in [CharTags]; see §30.3 Mapping character formats. By default, DITA2Go maps each character format that is not assigned a tag in [CharTags] to a CSS span class of the same name as the format, applying to the name any needed transformations (see §31.7.1 Understanding CSS class name restrictions).

For example, suppose your document uses character format names Emphasis, Prog Term, and Link, with the first two assigned HTML tags in [CharTags]. DITA2Go would treat these formats as follows, provided ClassIsTag=No (see §31.7.8 Using CSS class names as tags for XML): 

FM format name

[CharTags]

DITA2Go HTML output

DITA2Go CSS entry

Emphasis
Emphasis=em
<em>
em.emphasis {...}
Prog Term
Prog Term=code
<code>
code.progterm {...}
Link
(no setting)
<span class="link">
span.link {...}

If no tags are specified in [CharTags] for a particular character format, by default that format gets a span class.

To avoid creating CSS span classes for any character formats that are neither explicitly assigned an HTML tag nor explicitly assigned to a span class:

[CSS]
; UseSpanAsDefault = Yes (default, use span as element name
;  for all char formats that do not specify one in [CharTags]
;  or No
UseSpanAsDefault=No

When UseSpanAsDefault=Yes, any character format name not listed in [CharTags] is assigned to a span class of the same name as the format.

When UseSpanAsDefault=No, any character format name not listed in [CharTags] is skipped, and becomes just an override in HTML output.

To explicitly map an individual character format to a CSS span class:

[CharTags]
CharFormat=span
[CharClasses]
CharFormat=classname

Or:

[CharTags]
CharFormat=span class="classname"

You can use either method to assign <span class="classname"> tags, to define character formats globally in CSS. For example, if you map character format CodeBold to <span class="codebold">, DITA2Go inserts corresponding generic selector .codebold in the CSS file.

If you assign a class name to the same format in both [CharClasses] and [CharTags], and the class names are different, DITA2Go uses the [CharTags] setting for backward compatibility. See §30.3 Mapping character formats.

Generic XML

For generic XML output, see §23.3.1 Deriving XML tags from format and class names.

Previous Topic:  31.7.2 Mapping paragraph formats to CSS classes

Next Topic:  31.7.4 Assigning CSS classes to table formats

Parent Topic:  31.7 Assigning CSS classes

Sibling Topics:

31.7.1 Understanding CSS class name restrictions

31.7.2 Mapping paragraph formats to CSS 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