Vishal Vishwakarma
Vishal Vishwakarma

Reputation: 336

how to display html code without rendering on page?

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>

Upvotes: 4

Views: 7360

Answers (3)

Hackinet
Hackinet

Reputation: 3328

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>

Upvotes: 7

ParisaN
ParisaN

Reputation: 2082

Note : Use &lt;br&gt; for Line Break.

Upvotes: 1

anvin
anvin

Reputation: 560

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

Upvotes: 2

Related Questions