Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the special characters of HTML

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you what HTML special characters are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

HTML special symbol codes include many kinds of unicode, hexadecimal codes (hex code), html entity codes (entity code), and html entities (html entity) as we know them, and corresponding css code for use in the css content attribute.

You can insert hexadecimal codes (hex code), html entity codes (entity code) or html entities (html entity) directly into the HTML tag. When used in the css content attribute, you should use the corresponding css code.

It is important to note that some symbols are displayed differently depending on the font.

In project applications, there are times when you need to convert html and html code. Here are two ways to convert each other:

JavaScript Code:

Function html_encode (str) {var s = ""; if (str.length = = 0) return ""; s = str.replace (/ & / g, "&"); s = s.replace (/ / g, ">"); s = s.replace (/ / g, ""); s = s.replace (/\'/ g, "& apos;"); s = s.replace (/\ "/ g,") S = s.replace (/\ nCompact g, "

"); return s;} function html_decode (str) {var s ="; if (str.length==0) return ""; s = str.replace (/ & / g, "&"); s = s.replace (/ / g, ">"); s = s.replace (/ / g, ""); s = s.replace (/ & apos;/g, "\"); s = s.replace (/ "/ g,"\ ") S = s.replace (/

/ g, "\ n"); return s;}

Conversion can also be achieved using DOM's innerHTML and textContent by dynamically creating a container tag element, such as DIV, setting the string to be converted to the element's innerText, and then returning the element's innerHTML, which is the HTML-encoded string.

JavaScript Code:

Function html_encode (html) {return document.createElement ('div') .appendChild (document.createTextNode (html)) [xss_clean] [xss_clean];} function html_decode (html) {var a = document.createElement (' div'); a [XSS _ clean] = html; return a.textContent;}

HTML Arrows has sorted out the special symbols commonly used on most websites for your reference: https://www.toptal.com/designers/htmlarrows/

There are also arranged pictures below for everyone to save and use. Like what you like.

If you are also a front-end party, whether you are studying front-end development or already working, here is our front-end learning exchange group: 731771211, this is the place to illuminate your dreams and work hard for life. Help each other. Beginners can get the most cutting-edge front-end technical data after joining, update the technology from time to time, and keep pace with the needs of the enterprise. Friends are in the exchange, every day there will be Daniel regularly explain the front-end technology! Knowledge changes fate.

Click: join

The above is all the content of the article "what are the HTML Special characters?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report