Skip to main content

HTML Guide

Misplaced non-space characters inside a table.

The W3C HTML Validator issue “Misplaced non-space characters inside a table” usually occurs when there are text nodes (or other elements) that are not properly placed within table elements. In HTML, all text content should be contained within table cells.

How to Fix the Issue

To resolve this issue, ensure that all text content is placed inside <td> or <th> elements, which are the valid child elements of <table>, <tr>, and related elements. Here’s how you can identify and fix the issue:

Example of Incorrect Table Structure

<table>
  <tr>
    Hello World <!-- This is misplaced content -->
    <td>First Cell</td>
    <td>Second Cell</td>
  </tr>
</table>

Corrected Table Structure

<table>
  <tr>
    <td>Hello World</td> <!-- All text should be inside <td> or <th> -->
    <td>First Cell</td>
    <td>Second Cell</td>
  </tr>
</table>

Guidelines

  • Text Content: Ensure that all text (including any headers or titles) is wrapped in <td> (for data cells) or <th> (for header cells). Keep in mind that event the non-breaking space character (&nbsp;) counts as text.

  • Table Structure: Remember a typical structure for a table includes <table> containing one or more <tr> elements, which in turn contain the <td> or <th> elements.

  • No Direct Text Nodes: Avoid having any direct text nodes outside of the cell elements within the table.

Learn more:

Related W3C validator issues