Special HTML characters: description and use
HTML is a unique concept in programming. Before the Internet, programming was local. With the advent of local networks, it became multi-user and distributed, but it was not so cardinal a phenomenon as the idea of hypertext and its rapid development.
Features of special characters and hypertext
Before Internet programming, everything was strictly. There is data and there is a code that processes them. There are comments in which there can be no code.
Classical programming allowed only one exception: carriage return, line feed, tabulation and other “invisible” characters, but more correctly - actions. These are not HTML symbols yet, but only codes with special symbolic notation. Special characters were understood to mean that there is no place in the sets of "visible" characters, numbers and letters of national alphabets.
The comments quickly took the standard form:
- // - and everything until the end of a single line is NOT CODE;
- / * ... any text ...* / - here between "/ *" and "* /" there can be as many lines of any text as you like.
There has never been any code in the comments, no installations, no additions to the program code. Comments any programming language just missed. Hypertext went further (or did IE do it at the initiative of Microsoft?). First, here the comment is indicated:
- “<! -” is the beginning;
- "->" - the end, it is better to write "// ->".
Secondly, the comment can now be conditional. In itself, the appointment of a comment of a different meaning than “an explanation of the data and the code of the algorithm ...” is nonsense.
In this example, “comments”, highlighted by a crimson background, guarantee a fatal error of the HTML page.
Plain and special characters in HTML
Character codes matter. This is a completely different meaning than a letter, number or letter.
For example, the symbol “<” is the beginning of the tag and it is not always safe for any web page: the browser works with tags, and that says it all! The “<” symbol or the HTML “<” symbol are completely different things. But the "symbol" & lt; - it is always and everywhere a smaller sign, an angle bracket or another meaning that a person habitually puts into this outline.
Common Hypertext Symbols get a double meaning:
- they remain familiar and in demand;
- some characters become special.
Special HTML characters require special attention. For example, a preliminary backslash "\", escaping, digitizing, or mnemonic. For the browser line, all Cyrillic letters are “special characters”.
You can unsubscribe the problem of character encoding at the beginning of the computer era, when an eight-bit table contained only characters, numbers, Latin characters and the national alphabet (for example, Cyrillic). The rest of the characters were special, had mnemonic images, and were used for actions (printer control, port, internal or external devices). But the beginning of the computer era is not to blame; the problem was formed in a completely different place and in a different sense.
Hypertext and coding
There is no doubt that HTML and symbols are the task of how to use symbols to describe other symbols. Naturally, you will have to recognize some of the characters as special and use them to describe themselves and other characters. Despite frank blunders with comments, hypertext is an objective result of the development of information technologies and a brilliant solution to the problem of special characters.
There is so much attention paid to special characters on the Internet that the problem of coding a web page is the developer’s knowledge and skills. If the developer uses special HTML characters correctly, the site will work flawlessly and stably.
Each special character has a mnemonic, decimal and hexadecimal code. In various conditions of use it is permissible to use:
- any of these options;
- only one.
Not always and not every browser reports the erroneous use of a special character and defiantly goes into itself, presenting the developer with a white window. With the actual availability of knowledge and skills, the developer will never have problems in programming.
CSS, XML, HTML and symbols are one harmonious system, you just need to transform its logic into the necessary set of knowledge and skills. For example, in the code of the page '& laquo' is' '', but in the content CSS rule it is' \ 00AB '.
The concept and use of special characters allowed to create interesting ideas. Now you can not worry that the browser will understand something wrong. If it is “annoyed” by the & character or the space “”, you can use a mnemonic or a digital code.This dramatically increases the number of characters in the HTML code, but the result becomes reliable.
Simple complexity or complex simplicity
A rare site does without a regular expression. A great search and replace tool. But the regular expression language is not HTML characters, but the result that will be applied in the HTML code. Understanding and using regular expressions is a difficult task, but it is possible to get used to it, and it is even more effective to use it.
Basically, the server language easily converts special characters from one kind of representation to another. For example (PHP):
- $ cStrClean = str_replace ('<', '& lt;', $ cStrClean)
- $ cStrClean = str_replace ('& lt;', '<', $ cStrClean)
In regular expressions, everything is minimized to the limit, and the backslash "\", like Kyo's magician’s wand, works wonders. Any special character can be escaped with a slash and used as this one, and not as a symbol of a special operation.
Important:The script code page and / or web page must be correctly encoded. The string pattern of the regular expression too. In the event of a case, you should always transform, for example, Cyrillic characters into corresponding numeric codes.
The limits of the possible and the appropriate
In fact, any web resource is a source of information. A book is not a site, but also a source of information. Everyone is used to the fact that the book has text and illustrations. The text tends to “wrap around” the illustrations and align with the right border.
The use of computers and text editors has simplified the presentation and use of information, but one should not simply transfer this knowledge and skills to Internet programming and HTML pages. The hyphenation symbol, the end of the paragraph, the tabulation, etc. are demanded special characters that have practical significance, but it is better not to use them in Internet programming.
HTML is a conceptually complete solution. Here is everything you need for “all cases”. The fact that there is a bloop with comments is evidence of the speed of development of an idea, and not a fatal crack of a conceptual nature. There are a lot of absurdities in programming, but this is not a reason to break the foundation and build a new building from scratch.
Today there is a lot of other work and there is no reason to change something drastically. Developers are accustomed to the concept of HTML, the use of special HTML characters has been successfully implanted in it.Accumulated effective and practical experience. Practitioners can work quietly, and theorists no one bothers to develop new ideas.
Formalization, comments and languages
Knowledge and skills in the field of formalization are effective, extensive and practical. But the surest decision is to go further. Natural language is today the unattainable peak of perfection.
Comments in any code should contain a minimum of information and only for the sole purpose to explain something. There should be no code or special characters. The phrase, quoted in the comment body, can lead to a problem on the site page. Programming languages have long forgotten about the compatibility requirement. Free data types and targeting a specific version of a language for a developer are normal.
These three positions are sufficient grounds for the continuous development of knowledge and skills, the accumulation of practical experience in the development of stable, reliable and secure web resources. The most important feature of modern Internet programming is the rapid dynamics of development. To be aware and to control the situation is a good rule for a professional developer.