How to print html code?
Example:
<div id="css"><link rel="stylesheet" href="jquery.css.css"></div>
It does not print the link tag, it links to another css, I want to write that tag pro user read ...
How to print html code?
Example:
<div id="css"><link rel="stylesheet" href="jquery.css.css"></div>
It does not print the link tag, it links to another css, I want to write that tag pro user read ...
To do this you need to escape some special characters **
, for example:
" para "
' para '
& para &
< para <
> para >
To facilitate you can use the htmlentities
function.
The code:
<div id="css"><link rel="stylesheet" href="jquery.css.css"></div>
Equivalent:
<div id="css"><link rel="stylesheet"href="jquery.css.css"></div>
**
Others can be seen here .
Use <
instead of <
, and >
instead of >
.
You can print special characters in HTML using HTML Entities .
If you want you can use this here converter.
Server languages - such as PHP, Ruby, Python - have their own functions to convert a string to another with encoded characters.
When you go to print any text that was entered by the user (such as a post from a blog, for example) it is recommended to use this function to avoid JavaScript injection attacks . In this type of attack someone with malicious intent can write script
tags that will run on the user's machine without their consent.