What is the @outputclass attribute in DITA?

The @outputclass attribute in DITA is used to specify the styling or formatting of an element in the generated output formats. It provides a way to associate elements in DITA documents with custom styles or formatting instructions, allowing content creators to control the presentation of content in different output media, such as HTML, PDF, or other formats.

The @outputclass attribute serves to support formatting, output transformation, conditional styling, and reuse and consistency.

Formatting

Content creators can use the @outputclass attribute to assign custom CSS classes, styles, or formatting instructions to elements. These classes or styles can be defined in CSS (Cascading Style Sheets) or other styling mechanisms used by the output format. This allows for precise control over the visual appearance of content.

Output Transformation

When DITA content is transformed into different output formats (e.g., HTML, PDF), styles and formatting specified through the @outputclass attribute are applied accordingly. This ensures that the content maintains its intended look and feel across various media.

Conditional Styling

The @outputclass attribute can be used in conjunction with conditional processing attributes like @audience or @product to conditionally style content. For example, different styles can be defined for content intended for different audiences or products.

Reuse and Consistency

By using the @outputclass attribute consistently, organizations can maintain a standardized look and feel for their documentation. Styles and formatting can be reused across multiple documents and topics.

Example

A DITA document for a software user guide needs to highlight certain sections as “Important.” The @outputclass attribute can be used to achieve this:


        <topic>
            <title>Software User Guide</title>
            
            <section outputclass="important">
                <title>Installation</title>
                <p>This section explains how to install the software.</p>
            </section>
            
            <section>
                <title>Usage</title>
                <p>This section covers how to use the software.</p>
            </section>
        </topic>
    

In this example, the @outputclass attribute is applied to the first

element, indicating that it should be styled as “important” in the output. When this DITA document is transformed into an HTML or PDF output, the CSS or styling rules associated with the “important” class will be applied to this section, making it stand out visually.