Search
 
SCRIPT & CODE EXAMPLE
 

HTML

html escape characters

Escapes or unescapes an HTML file removing traces of offending characters that could be wrongfully interpreted as markup.

The following characters are reserved in HTML and must be replaced with their corresponding HTML entities:

" is replaced with "
& is replaced with &
< is replaced with &lt;
> is replaced with &gt;
Comment

how to escape in html

Escaping HTML characters in a string means replacing the:
1.less than symbol (<) with &lt;
2.greater than symbol (>) with &gt;
3.double quotes (") with &quot;
4.single quote (') with &#39;
5.ampersand (&) with &amp;
 ------------------------------
function escape(htmlStr) {
   return htmlStr.replace(/&/g, "&amp;")
         .replace(/</g, "&lt;")
         .replace(/>/g, "&gt;")
         .replace(/"/g, "&quot;")
         .replace(/'/g, "&#39;");        

}

console.log(escape("<script>alert('hi')</script>"));
Comment

PREVIOUS NEXT
Code Example
Html :: see line from table html 
Html :: iframe maps 
Html :: tailwind css radio 
Html :: change color on the same string html 
Html :: underline hover mouse 
Html :: div table bootstrap 4 
Html :: html auto redirect 
Html :: submit and open another page 
Html :: html submit button text 
Html :: HTML5 Option Groups 
Html :: what is dir attribute in html 
Html :: bootstrap table combine columns 
Html :: blue glow input boostrap 4 
Html :: euro html 
Html :: how to define tag icon in html 
Html :: datatable pdfHtml5 pagesize 
Html :: php prevent form resubmission 
Html :: at sign html 
Html :: how to align span to right 
Html :: html meta tags for seo 
Html :: stop website from overscrolling 
Html :: Change color of calendar icon in HTML Date Input 
Html :: figcaption html 
Html :: html video loop 
Html :: how to eliminate scroll bar in html 
Html :: onclick to next page in html 
Html :: how to disable shadow in bootstrap button 
Html :: how to get text in middle of page html 
Html :: html table multiple headers 
Html :: html target 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =