0

I'm trying to use markup to create a Text node in an html document which does not affect the presentation and has no semantic meaning in order to get the :empty pseudo-class to trigger.

Here's the code (copied from here):

th::after { content: attr(data-value) }
td::after { content: attr(data-value) }
td[data-value]:not(:empty) {
  color: fuchsia;
}
<table>
  <tr>
    <th data-value="Peter"></th>
    <td data-value="male">&#x0200B;</td>
    <td data-value="34"></td>
  </tr>
  <tr>
    <th data-value="Susanne"></th>
    <td data-value="female"></td>
    <td data-value="12"></td>
  </tr>
  <tr>
    <th data-value="Lucas"></th>
    <td data-value="male">&#x0200B;</td>
    <td data-value="41"></td>
  </tr>
</table>

After reviewing the Character Entity Reference Chart it's unclear to me if the ZeroWidthSpace would be suitable for this purpose:

<td>&ZeroWidthSpace;</td>

Is there a way to use html markup to create Text nodes without any semantic meaning?

vhs
  • 9,316
  • 3
  • 66
  • 70

2 Answers2

0
ALT+0160
&nbsp;
&#160;
\00A0

This might work? It's a non-breaking space

Jaapaap
  • 221
  • 1
  • 5
  • Thanks for the quick answer! This would be great except for fact they can affect the presentation slightly—why I went with the ZeroWidthSpace. Welcome to SO! – vhs Jan 09 '19 at 12:11
  • Marking answered as no better answers have been given. Thanks again. – vhs Jul 05 '19 at 03:19
0

Over a year later I learned there is indeed a null entity reference to create a text node without any meaning:

&#0; also written as &#x0;.

Depending on one's interpretation of "no meaning" in the context of other questions, additional potential answers include:

  • &#x2400; or the ␀ character NUL
  • &#x2205; or the ∅ character Empty Set
vhs
  • 9,316
  • 3
  • 66
  • 70