A simple space and a special character are similaronly one thing: they mean the separation of words, tags, attributes and other markup elements. However, the use of an ordinary space is important only to improve the readability of the content of the page and for the convenience of working with it in a text editor.
For the browser and its JavaScript language, the amount of space between words, tags, and other elements does not matter.
Space is the most necessary character.Although it is "empty", but very useful. Even in the good old days, when such symbols as "line feed" and "carriage return" were important, any number of spaces anywhere in the code was used only to increase its readability. But in itself an empty space "was very much appreciated."
Correctly manipulate words, key wordswords and syntactic constructions, no compiler (interpreter) has learned to distinguish the program code from the comment to this day. Without any significant tokens like Pascal: "=" and PE (1) ";", currency-oriented innovation "Pahape" (PHP) - "$" in the name of the variable was treated, except that "Fortran", whose each operator should be on a separate line.
Fundamentally said means thatthe natural ability to separate words and phrases, to distinguish phrases from sentences, and in the latter to catch the finished meaning, artificial languages still do not exist.
But a simple blank can be in any number inany line, and it has a mandatory numeric code. A space is not an empty place in either the code or the value of a variable. This is a very important symbol. Hence, the value has nbsp. What is it? Now consider.
Many areas of application of the letter and the withdrawal of content require strict adherence to the rules of registration. A simple example is lists.
Wrong list:
Correct list:
Here the symbol "_" denotes a simple space that can be specified by mistake or is formed due to alignment of the text of the list item on both sides of the paragraph.
Basically, the content of the list itemmust follow immediately after the number. In particular, the text editor MS Word even at the very beginning of its existence suggested using an indissoluble space (the combination of keys ctrl + "space") to prohibit a break between the elements of the string.
A non-breaking gap stuck together two adjacent words,and it is not necessary that both of them be such. And in the case of lists, when the element number is not included in the content of the paragraph, the gluing is performed to the beginning of the line.
In those days, when MS Word already usedinvariable success, the language of hypertext was still being formed, but the presence of special symbols in it was assumed initially. Another thing & nbsp - what it is and why it is needed, was not immediately clear.
The correct title is not broken, and the words in it are not transferred. It is centered or aligned on one side or the other. It is difficult to do without using an indissoluble blank.
In the hypertext language, this would look like this:
7. 5. FreeBSD Installation Guide
On the HTML page in the browser, the header number will look like this: "7. 5." and all the headers thus created will be exactly the same.
There is a point to pay attention to,if the header uses text and picture. The browser displays everything sequentially, just as defined by the incoming thread. The img tag is located at the very beginning of the line, but to fit the text immediately behind the picture, you need to take into account its width.
Absolute positioning of the text in rare cases can help. Usually, headings and text go in one thread, but with different tags, for example h2 and p.
To move the text to the right of the picture, it is very convenient to apply a few.
In the following example, you need to display the icons for the types of files to be downloaded and write a number of corresponding extensions with text.
Coding is done in PHP using nbsp. What is it and how is it used? Now it becomes clear. Similarly, the non-breaking space character is used in JavaScript.
When processing strings (both on the server and insidebrowser) the non-breaking space is not used - it is too expensive to apply instead of one significant symbol "", as many as six "". However, when a string is sent to the output in the browser stream, it is necessary to recode all the space characters in the proper number of non-breaking spaces.
Outputting more than one space in the echo or print_r sequence will not have the desired effect and the content will "crawl". For example (PHP):
Will have a different effect if the tag has justify alignment. In the first case, the number 2 will be printed from the left edge of the block to which the conclusion was drawn, and the text "Hi!" - From the right.
Meanwhile, the problem is not in the gaps.Unprintable characters are actually very many, and not always they are used correctly. It's worth remembering how MS Word users make out the documents. When you need to write the word "director" on the left, and his last name on the right, the vast majority form several tabs in a row - quickly and effectively.
Instead of correctly setting the tab-value and aligning it on the tab, the user clicks the tab several times and gets the desired effect.
A similar situation is in the markup language HTML. Many developers do not use special characters correctly, do not apply the necessary styles as it should be done, and the result: "Hello World, I made a mistake for the third time ..." - will be stretched across the width of the block to which this line was output.
If you recode the line in "Hello World, I'm wrong the third time ..." - the result will be exactly what it should be.
Knowing and using special symbols is a very good idea. Especially if you have a desire to make effective and quality pages, in which the content is located accurately and accurately.