问题
How do I print the "html" tag, including '<' and '>'? How can I do this for any tag, without using text areas and Javascript?
回答1:
Use HTML character references:
<html>
Should output
<html>
回答2:
Try doing:
<html>
回答3:
Special characters in HTML, such as '<', '>', '"' and '&' can be printed using the following format:
&name;
where name would be replaced by a character name. The most common would then be
< = < (less than)
> = > (greater than)
& = & (ampersand)
" = " (double quote)
So to write <html> you would write in HTML:
<html>
回答4:
If you want to display <html>
literally, use reference to represent the tag open delimiter <
and the tag close delimiter >
, for example:
<html>
This will then be displayed as:
<html>
回答5:
do this
<html>
回答6:
Please have a look at html entities
You can use the entity names directly in your html.
<p> <html> </p>
will render as <html>
.
likewise
<p> 3 > 2 </p>
will render as 3 > 2
.
Try all the html entities and check the output in this Fiddle
回答7:
<html>
my output code <HTML>
回答8:
To print an HTML tag write
<html>
or <html>
both gives the same output : <html>
来源:https://stackoverflow.com/questions/3505047/printing-html-using-html