[TeX] \tag can generate invalid IDs
E.g.,
\begin{equation}
x \tag{Y $x$}
\end{equation}
creates (on any output) an element with id="mjx-eqn-Y $x$_1"
which is not a valid ID due to the space.
Since IDs can end up in SVG elements, they should ideally be a valid XML IDs to pass validation but stripping spaces probably covers most use cases.