<row>: How are individual rows created and formatted within tables using the <row> element in DITA?

The <row> element in DITA is used to create and format individual rows within tables. Rows are a fundamental part of table structures, and they contain the actual data or content organized into cells represented by <entry> elements. Properly formatting rows is essential for presenting tabular information effectively and ensuring clarity for readers.

Creating Rows

To create a row within a table, you use the <row> element. Each <row> typically corresponds to a single row of data in the table. Within a <row>, you can include one or more <entry> elements, which represent individual cells in that row. These cells can contain text, images, links, or any other content that you want to present in the table.

Formatting Rows

Formatting rows in DITA is achieved through the proper use of styling and attributes. You can use CSS (Cascading Style Sheets) to control the appearance of table rows, such as setting background colors, borders, padding, and text formatting. Additionally, DITA provides attributes like @valign (for vertical alignment) and @align (for horizontal alignment) that allow you to fine-tune the presentation of rows and cells.

Example:

Here’s an example of how the <row> element is used to create and format rows within a DITA table:


<table id="sample_table">
  <thead>
    <row>
      <entry>Product Name</strong></entry>
      <entry>Category</strong></entry>
      <entry>Price</strong></entry>
    </row>
  </thead>
  <tbody>
    <row>
      <entry>Product A</entry>
      <entry>Electronics</entry>
      <entry>$499.99</entry>
    </row>
    <row>
      <entry>Product B</entry>
      <entry>Home & Garden</entry>
      <entry>$299.95</entry>
    </row>
    <!-- Additional data rows -->
  </tbody>
</table>

In this example, the <row> element is used within the <tbody> section to create data rows in the table. The formatting of rows, such as bold text in the header row and data content in subsequent rows, enhances the readability and visual organization of the table.