-1

When i say this, i mean how do i make a specific piece of code show not as part of the actual website, but as a demonstration for others to see?

kuz
  • 1
  • 1
    Does this answer your question? [How to show
    tag literally in /
     tag?](https://stackoverflow.com/questions/11386586/how-to-show-div-tag-literally-in-code-pre-tag)
    – ikiK Jun 13 '20 at 21:28

3 Answers3

1

There are various ways to do so

  1. You may use <pre></pre> tag
<pre>
   your-code
</pre>
  1. using special <code> tag
<pre>
  <code>
    your-code
  </code>
</pre>
  1. you may like to use the HTML code within
<![CDATA[<your-code>]]>
  1. use any syntax highligtening library e.g. prettify or syntaxhighlighter
Swatantra Kumar
  • 1,161
  • 5
  • 24
  • 29
1

You will have to use:

  1. The <pre> - Preformatted tag to display the html text
  2. The &lt; - Less than tag in place of < tag in your code
  3. The &gt; - Greater than tag in place of > tag in your code.

    i.e <div> shall be replaced by &lt;div&gt;

Brief example

<pre>
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;h1&gt;The code element&lt;/h1&gt;

&lt;p&gt;The HTML &lt;code&gt;button&lt;/code&gt; tag defines a clickable button.&lt;/p&gt;

&lt;p&gt;The CSS &lt;code&gt;background-color&lt;/code&gt; property defines the background color of an element.&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
Lefty
  • 605
  • 7
  • 11
0
<pre>
<code>
you code here 
</code>
</pre>
belhadj abdou
  • 150
  • 3
  • 15