How do you ensure consistent styling across tables in DITA?

Consistent styling in DITA tables can be ensured by defining and applying a common CSS (Cascading Style Sheets) or other styling mechanism across all tables in a documentation set. This approach maintains a uniform appearance and formatting for tables, making content look cohesive, consistent, and professional.

How to Maintain Consistent Styling

Maintaining this consistent styling can be achieved by creating a common CSS style, using an external CSS, and referencing using CSS classes or IDs.

Create a Common CSS Style

Develop a CSS style specifically for DITA tables. This style should include rules for table elements such as <table>, <th> (table headers), <td> (table cells), and any other relevant elements. This CSS should encompass the desired font styles, colors, padding, border styles, and other visual properties.

External CSS

It’s advisable to create an external CSS file that contains the table styling rules. This way, this CSS file can be linked to all DITA documents that contain tables. External CSS files allow for easy updates and consistency enforcement across multiple documents.

CSS Classes or IDs

Within DITA documents, CSS classes or IDs can be assigned to tables or individual table elements. Applying these classes or IDs ensures that defined CSS rules are consistently used. CSS classes are particularly useful for maintaining uniformity because they can be reused across multiple tables.

Example: External CSS

An external CSS file, “dita-table-styles.css,” is created to define table styles.

/* dita-table-styles.css */
.dita-table {
  font-family: Arial, sans-serif;
  font-size: 14px;
  border-collapse: collapse;
  border: 1px solid #ccc;
  background-color: #f5f5f5;
.dita-table th, .dita-table td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: left;
.dita-table th {
  background-color: #333;
  color: #fff;

This CSS file can be referenced by tables in DITA documents by applying the “dita-table” class.

Example: DITA Document with a Table

A DITA document with a table that references the external CSS file:

<link rel="stylesheet" type="text/css" href="dita-table-styles.css">
<table class="dita-table">
  <tgroup cols="2">
        <entry>Header 1</entry>
        <entry>Header 2</entry>
        <entry>Data 1</entry>
        <entry>Data 2</entry>