Do you have to? Yes. But first, clarification for a couple of points.
Sending the Content-Type: application/xhtml+xml header means it has to go through the XML parser, it still has all the advantages of HTML5, as far as I can tell.
About which is not defined in XML, the only character that references XML is lt, gt, apos, quot and amp, you will need to use numeric character references for anything else. Code for nbsp:   or   , I personally prefer hex because Unicode code codes are represented in this way (U + 00A0).
Submitting the header is useful for testing because you can quickly find problems with your markup, such as unclosed tags, tags with private tags, text that can be interpreted as a tag, etc., basically things that can disrupt the appearance or even the functionality of your site.
The most important thing, in my opinion, is that you allow the user to enter data and do not understand this, which usually means that you do not avoid their data and leave yourself vulnerable. Parsed as HTML, you may never notice a problem until someone starts to enter scripts to bother your users or steal data.
This page is pretty good at explaining what polyglot markup is: https://blog.whatwg.org/xhtml5-in-a-nutshell
Chinoto vokro
source share