Reputation: 91
I want to be able to make code show up on my website so that it shows up with the code on the webpage instead of using it as code in the HTML file itself.
Example:
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
Instead of:
Hello World
I know I explained that horribly but I'm sure you can see where I'm coming from. Can you escape in HTML? Or is there a tag that allows for HTML code to be viewed as text on a webpage?
Upvotes: 0
Views: 2400
Reputation: 876
xmp tag
<!DOCTYPE html>
<html>
<body>
<xmp><p>Hello World</p></xmp>
</body>
</html>
keep in mind that xmp
tag is considered obsolete, as far as I know it is still supported by most browser but your mileage may vary.
you are safer if you use <pre>
and escape html code with <
and >
like this
<!DOCTYPE html>
<html>
<body>
<pre><p>Hello World</p></pre>
</body>
</html>
Upvotes: 4
Reputation: 903
You can use the xmp property. Anything inside the xmp that is exempted by the browser while rendering the HTML code.
Example :
<xmp><h1>Heading</h1></xmp>
Upvotes: 0
Reputation: 591
There is similar question answered on this link: Display HTML code in HTML
In addition, have a look at the following websites
https://craig.is/making/rainbows
Upvotes: 1