Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show source code without XMP tag

Tags:

html

xmp

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.

like image 216
Cătălin George Feștilă Avatar asked Jan 28 '26 11:01

Cătălin George Feștilă


1 Answers

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.

like image 98
Ben Companjen Avatar answered Jan 31 '26 05:01

Ben Companjen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!