Home  >  Article  >  Web Front-end  >  How to display html code directly in html

How to display html code directly in html

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-04-30 09:30:245785browse

This article will introduce to you how to directly display html code in html. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to display html code directly in html

Baidu has listed a lot of practices, and I feel that many of them have not been tested before making nonsense. I will summarize them here.
Baidu refers to the <code><code> and <code><pre class="brush:php;toolbar:false"></pre> tags. My test results are as follows:

1.<code>

<code>
    <h1>hello</h1>
    <h2>hello</h2>
      <h3>hello</h3>
      <h4>hello</h4>
    <h5>hello</h5>
    <h6>hello</h6>
  </code>

Rendering:
How to display html code directly in html
The code is still rendered and fails. It is said that inline elements are rendered, but they are still rendered if they are changed to span.

2.<pre class="brush:php;toolbar:false"></pre>

Code:

<pre class="brush:php;toolbar:false">
    <h1>hello</h1>
    <h2>hello</h2>
      <h3>hello</h3>
      <h4>hello</h4>
    <h5>hello</h5>
    <h6>hello</h6>
  

Rendering:

How to display html code directly in html
Same as above render.

3.

Code:

<xmp>
    <h1>hello</h1>
    <h2>hello</h2>
      <h3>hello</h3>
      <h4>hello</h4>
    <h5>hello</h5>
    <h6>hello</h6>
  </xmp>

Rendering:
How to display html code directly in html

Display directly And the format is preserved! feasible!

Recommended learning: html video tutorial

The above is the detailed content of How to display html code directly in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete