I read that xmp tag is deprecated, but I need to output code as plain text. So is there some way how to simulate xmp tag behavior? Thanks for help.
You cannot simulate the special parsing mode of xmp
elements in HTML, except in genuine XHTML (i.e., XHTML served with an XML media type), where you can use CDATA
sections. The reason is that this is about low-level parsing of HTML, hard-wired into browsers.
So if you don’t want to use xmp
, the only way is to “escape” the characters “&” and “<” in the content. Note that HTML5 drafts require browsers to keep supporting xmp
(while declaring it as obsolete and forbidden).