How to display HTML tags as text

How can I display HTML tags on an .html page without trying my browser to do everything the tag has.

+4
source share
3 answers

You must use the shielded version. For example, < becomes &lt; (without quotes) and & becomes &amp; .

You should be able to find a complete list of conversions.

Fragment example:

 &lt;a href="http://google.com"&gt;Google&lt;/a&gt; 

is a shielded version:

 <a href="http://google.com">Google</a> 

Edit:

Standard list of objects: http://www.w3.org/TR/html4/sgml/entities.html

Wikipedia artcile on it: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

+12
source

You can use the php function " highlight_string(); " for example:

 <?php highlight_string('<?php phpinfo(); ?>'); ?> 

It will output the input as a color-coded string.
check out your php documentation: http://php.net/manual/en/function.highlight-string.php

0
source

The response to the insertion of tags into the body part can be passed through the <textarea> . Text or tags entered between the open and close <textarea> tags will be displayed as such.

-2
source

Source: https://habr.com/ru/post/1387147/


All Articles