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 :: yellow html 
Html :: how to display the first frame of the video element in html 
Html :: refused to connect iframe php 
Html :: ejs ternary 
Html :: bootstrap 5 accordion 
Html :: html image 
Html :: show scrollbar only when scrolling 
Html :: html table row span 
Html :: html scrollable table vertical 
Html :: plantuml font size 
Html :: how to add image in html 
Html :: difference between xhtml and html 
Html :: ionic skeleton 
Html :: django python variable in html 
Html :: how to change font color of h2 tag in html 
Html :: what does html stand for 
Html :: bootstrap 5 navbar not working 
Html :: change font size of input text html 
Html :: bootstrap gutter 
Html :: html table 
Html :: html scale svg 
Html :: add color to hr tag 
Html :: picsum 
Html :: bootstrap 4 button link 
Html :: html percentage 
Html :: bootstrap 4 multiple file upload 
Html :: html insert image 
Html :: get id value of html dropdown in jquery 
Html :: vuejs v-on 
Html :: html to text npm 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =