Are there considerations for mobile responsiveness in DITA tables?

Considerations for mobile responsiveness with DITA tables are essential to ensure that tables adapt well to different screen sizes and devices. Responsive design for DITA tables involves media queries, table layout, and column flexibility.

Media Queries

Use CSS media queries to define different styles for various screen sizes (e.g., desktop, tablet, and mobile). Media queries allow the application of specific styles to tables depending on the available screen space.

Table Layout

Consider using CSS properties like <code>table-layout: auto</code>, <code>table-layout: fixed</code>, or <code>width: 100%</code> to control how tables expand or shrink to fit the screen width.

Column Flexibility

Use CSS to set column widths as percentages (e.g., <code>width: 33%</code>) to allow columns to scale proportionally based on screen width.

Considerations for Mobile Responsiveness:

Stacked Rows: On narrow screens, consider stacking content vertically instead of displaying side by side. This simplifies the layout for small screens.

Font Size: Ensure that text within table cells is legible on smaller screens by adjusting font sizes appropriately.

Horizontal Scrolling: Avoid horizontal scrolling on mobile devices. Tables should fit within the screen width, and users should not need to scroll sideways to see the content.

Hidden Columns: On smaller screens, consider hiding less critical columns or providing a way for users to expand to see additional columns.


    <caption>Product Comparison</caption>
      <col style="width: 25%"></col>
      <col style="width: 25%"></col>
      <col style="width: 25%"></col>
      <col style="width: 25%"></col>
      <!-- Additional rows -->

For mobile responsiveness, CSS media queries could be applied to stack the table rows and make other adjustments:

    /* Sample CSS for Mobile Responsiveness */
    /* For mobile devices */
    @media screen and (max-width: 600px) {
      table {
        width: 100%; /* Make the table expand to full width */
      tr {
        display: block; /* Stack rows vertically */
      th, td {
        display: block; /* Stack header and data cells */
        width: 100%; /* Expand cells to full width */

In this example, the CSS code restructures the table for mobile devices by stacking rows and adjusting cell widths, ensuring a better mobile user experience. The exact styles and media query breakpoints can be customized to fit the specific design requirements.