2

I want to display HTML code as it is without rendering.

Current Output

Note : Use
for Line Break.

Expected Output

Note : Use <br> for Line Break.

<html>
<head>
</head>
<body>
  Note : Use <br> for Line Break.
</body>
</html>

3 Answers3

2

You can show HTML tags as plain text in HTML on a website or webpage by replacing < with &lt; or &60; and > with &gt; or &62; on each HTML tag that you want to be visible. Ordinarily, HTML tags are not visible to the reader on the browser.

Also you can look into this question: Display HTML snippets in HTML

anvin
  • 247
  • 1
  • 4
  • 15
2

Method 1


You can use <xmp> but it's deprecated as suggested by @Someone_who_likes_SE. So probably avoid using it.

Mozilla XMP Documentation states:

The HTML element renders text between the start and end tags without interpreting the HTML in between and using a monospaced font.

<html>
<body>
  <xmp>Note : Use <br> for Line Break.</xmp>
</body>
</html>

Method 2


We generally replace the tag brackets with their HTML entities codes

< becomes &lt; and > becomes &gt;

<html>
    <body>
      Note : Use &lt;br&gt; for Line Break.
    </body>
    </html>
Hackinet
  • 3,007
  • 1
  • 9
  • 20
1
Note : Use &lt;br&gt; for Line Break.
ParisaN
  • 1,397
  • 2
  • 18
  • 47