• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Learning DITA

Free DITA training

Free DITA training

  • Log in
  • Register
  • Newsletter
  • Profile
  • Privacy
  • Home
  • About
  • Courses
  • News
  • Resources
  • Support the site
  • Contact
  • Recordings

Adding tables to a concept topic

Posted on 08.30.15

Use the <table> element when you need to create a larger or more complex table than you can with the <simpletable> element. If you need a title or caption for your table, or more than one header row, the <table> element is the best option.

The elements contained in the <table> element include:

<title> The container element for the text of a <table> element’s title or caption. A <table> element can only contain one <title> element.
<tgroup> The container element for the main content of a <table> element. The <tgroup> element contains the <colspec>, <thead>, and <tbody> elements. A <table> element can contain one or more <tgroup> elements.
<colspec> The element that provides information about the columns in a <table> element. The column specifications are defined using the colname (the name of the column), colnum (the order in which the column appears), and colwidth (the relative width of the column) attributes.
<thead> The container element for the header in a <table> element. The <thead> element can contain one or more <row> elements and is optional.
<tbody> The container element for the body rows in a <table> element. The <tbody> element can contain one or more <row> elements.
<row> The container element for a row of cells in a <table> element. The <row> element contains one or more <entry> elements.
<entry> The container element for a single cell in a <table> element. The <entry> element contains the text of a cell in the <table> element, which should be wrapped in a <p> element according to best practice.

This lesson will cover the basics of using the <table> element. To highlight the differences between the <table> and <simpletable> elements, you will be using the same sample content for your <table> exercise as you used for your <simpletable> exercise.

Figure 2. Example <table> in a visual format

Continue using the file lesson2/l_concept_images_tables_start.dita to add the <simpletable> and <table> elements.

Note:

If you are using a DITA editor, some child elements of the <table> elements will automatically be inserted as you work through the examples.

Video: Creating a table in DITA

Note:

This video shows an alternative way to create a table in DITA using the oXygen XML Editor table wizard. The exercises show you how to create a table using DITA code.

Practice
  1. After the <simpletable> element, add a <table> element as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
      <conbody>
    ...
    </simpletable>
    <table>
    </table>

       </conbody>
    </concept>
  2. Inside the <table> element, add a <title> element and add content to it as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
      <conbody>
    ...
    <table>
    <title>Typical development of mallard ducks</title>
    </table>
    </conbody>
    </concept>
    The <title> element is optional, but it allows you to add context to your table, just as it does for images when used inside the <fig> element.
  3. After the <title> element, add the <tgroup> element as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
       <conbody>
    ...
    <title>Typical development of mallard ducks</title>
    <tgroup cols="2">
    </tgroup>

    ...
    </conbody>
    </concept>
    The <tgroup> element contains the body of the table. The number of table columns is set inside the <tgroup> element using the cols attribute. In the example you added, cols=”2″ shows that this table will contain two columns.
    A single <table> element can contain more than one <tgroup> element, which is useful if you need to show more than one table with different headers or numbers of columns under the same title.
  4. Inside the <tgroup> element, add two <colspec> elements and add content to them as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
       <conbody>
    ...
    <tgroup cols="2">
    <colspec colname="c1" colnum="1" colwidth="1.0*"/>
    <colspec colname="c2" colnum="2" colwidth="1.0*"/>

    ...
    </conbody>
    </concept>
    The <colspec> element sets up your table columns and specifies information about them (such as their names, sequence, and widths) using attributes. In the example you added, the colname attribute was used to name your columns “c1” and “c2” and the colnum attribute was used to designate the order in which these columns appear.
    The optional colwidth attribute can be used to control the proportions of the column widths. In the example you added, the colwidth attribute is the same for each column, meaning that they will display at equal widths.
  5. After the last <colspec> element, add the <thead> element as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
       <conbody>
    ...
    <colspec colname="c2" colnum="2" colwidth="1.0*"/>
    <thead>
    </thead>

    ...
    </conbody>
    </concept>
    The <thead> element contains the elements associated with the table header. Unlike the <sthead> element in a <simpletable> element, the <thead> element in a <table> element can contain more than one header row.
  6. Inside the <thead> element, add the <row> element as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
       <conbody>
    ...
    <thead>
     <row>
    </row>

    ...
    </concept>
    The <row> element contains the elements associated with a table row.
  7. Inside the <row> element, add two <entry> elements and add content to them as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
      <conbody>
    ...
    <row>
    <entry><p>Age</p></entry>
    <entry><p>Milestone</p></entry>

    ...
    </concept>
    Each <entry> element corresponds to a single table cell in a row. In the example you added, each <entry> element follows the best practice of wrapping a <p> element surrounding the text.
  8. After the <thead> element, add the <tbody> element as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
      <conbody>
    ...
    </thead>
    <tbody>
    </tbody>

    ...
    </conbody>
    </concept>
    The <tbody> element is for the main body of the table. Following the same structure as the <thead> element, the <tbody> element can contain <row> elements with <entry> elements inside them.
  9. Inside the <tbody> element, add a <row> element and add content to it with <entry> elements and their containing text as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
      <conbody>
    ...
    <tbody>
    <row>
    <entry><p>7 weeks</p></entry>
    <entry><p>Attempt flight for the first time</p></entry>
    </row>

    ...
    </concept>
  10. After the <row> element you just added, add two more rows and add content to them as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    <concept id="concept_images_tables">
       <title>Duckling growth and development</title>
       <conbody>
    ...
    </row>
    <row>
    <entry><p>12-14 weeks</p></entry>
    <entry><p>Reach adult body weight</p></entry>
    </row>
    <row>
    <entry><p>1 year</p></entry>
    <entry><p>Capable of reproduction</p></entry>
    </row>

    ...
    </concept>
    The <tbody> element can contain one or more <row> elements.
    Video: Creating a table in DITA
  11. Check your file lesson2/l_concept_images_tables_start.dita against the sample file lesson2/l_concept_images_tables.dita.
Practice
  1. Open the file lesson2/l_concept_images_tables_exercise_start.dita and use it to convert the following untagged content into DITA:
    Use the sample image lesson2/images/configurebetter1.png for this exercise.

    Source: Content Strategy 101

  2. Check your file lesson2/l_concept_images_tables_start.dita against the sample file lesson2/l_concept_images_tables_exercise.dita.
Contributors
  • Gretyl Kinsey, Scriptorium

sidebar

Blog Sidebar

  • Scriptorium logo
    Maximize the value of your content. Read more.
  • Scriptorium logo
    Already in DITA and need support? Contact us.
RSSTwitter

Want to add content? Join the ditatraining GitHub repository.

  • Home
  • Sponsor
  • News
  • Contact
  • Privacy
  • Cookie Policy

Maintained by Scriptorium Publishing

Logo and site presentation © 2015-2023 Scriptorium Publishing. Content based on the open-source DITA training project.

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}