Format HTML table: Template for frames, columns without frames

Formatting HTML tables – Today a small basic from practice. Many customers wanted to create their own texts with their employees in WordPress. So that the text is also optimized for search engines, several small features are added. These can be for example photos from the media library but also Youtube video embeddings. Tables simply with Copy & pasting brings a lot of HTML snippets with it, which you don’t want in your own content management system. Let’s take a look at the example of a simple HTML table that anyone can generate and modify.

Problem: Simply copying HTML tables is unclean

For employees in companies it is important, they should not copy any tables, otherwise we have, as described, a lot of “trash” in our HTML code. The HTML code is not visible in the “visual” area of the editor. To edit it you have to click on “Text” in WordPress Editor. If code is simply copied, it takes small snippets with it that we don’t want. Here is a direct example from practice:

Example – Bad HTML of a table

There are now many things copied here that are not visible:

<th class=”headerSort” tabindex=”0″ title=”Sort Ascending” role=”columnheader button”>No.</th>
<th class=”headerSort” tabindex=”0″ title=”Sort in ascending order” role=”columnheader button”>district</th&gt
<th class=”headerSort” tabindex=”0″ title=”Sort in ascending order” role=”columnheader button”>area</th>

So we see that Copy & Paste takes a lot of stuff away.

Example – Good HTML of a table

That way it would look clean:

<th>No.</th>
<th>District</th>
<th>area</th>

Solution: HTML table template

You have to use or get to know a little bit of HTML. It is best to save it for a short time and then copy or edit it:

  • Tip1 :
    and only at the beginning

    only at the end

  • Tip 2: use it only in the first line and close it again (th means “Table Headline)
  • Tip 3:
    opens a row and

    closes it (tr means “Table Row”)

  • Tip 4: opens a value or a box and

    closes it (td means “Table Data”)

  • Here is a table with 3 columns and 3 rows:

    <table>
    <tbody>
    <carry>
    <th>heading 1</th>
    <th>Heading 2</th>
    <th>Heading 3</th&gt
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    </tr>
    </tbody>
    </table>

    This is what the finished table looks like:

    heading 1 heading 2 heading 3
    text 1 text 2 text 3
    text 1 text 2 text 3

    Another example with 2 columns and 2 rows:

    <table>
    <tbody>
    <carry>
    <th>heading 1</th>
    <th>Heading 2</th>
    </tr>
    <carries;
    <td>Text 1</td>
    <td>Text 2</td>
    </tr>
    </tbody>
    </table>

    Another example with 4 columns and 5 rows

    <table>
    <tbody>
    <table>
    <th>Heading 1</th>
    <th>Heading 2</th>
    <th>Heading 3</th>
    <th>Heading 4</th&gt
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    <td>Text 4</td>
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    <td>Text 4</td>
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    <td>Text 4</td>
    </tr>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    <td>Text 4</td>
    </tr></tbody>
    </table>

    Add more columns and rows

    You get more rows by starting or closing a new table row within your table <table>…</table> each time. This looks like this:

    <carry>

    </td>

    Depending on the number of columns, the “Table Data” must be inserted
    <carries;
    <td>Text 1</td>
    <td>Text 2</td>
    <td>Text 3</td>
    <td>Text 4</td>
    </tr>