Show source code without XMP tag

梦想与她 提交于 2019-12-13 17:08:50

问题


How do I show HTML markup including tags without using the XMP element on an HTML5 website?

The website is made with HTML5 and shows tutorials about HTML, C++ etc.

So I need to show the source code of many programming languages.


回答1:


The most often used alternative is to use the <pre> or <code> element and escape characters that have a special meaning in HTML. < would become &lt;, > is escaped to &gt;.

According to Can I escape html tags within a class (recreate the xmp tag)?, you can still use the XMP tag. Browsers should still support it, although according to What was the <XMP> tag used for?, <pre> is the preferred element to use.



来源:https://stackoverflow.com/questions/15156549/show-source-code-without-xmp-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!