ComputersInformation Technology

NBSP - what is it? Empty place of importance

A simple space and a special character & nbsp; Are similar in only one: they mean the separation of words, tags, attributes and other markup elements. However, using the usual space is only relevant to improve the readability of the page content and for the sake of convenience in 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.

Applying spaces

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, keywords and syntactic constructions, to distinguish the program code from the comment to this day, no compiler (interpreter) has learned. Without any significant tokens like Pascal: "=" and PEEL (PL / 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.

Essentially said means that the 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 on any 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.

The ideal system: what is not, but so necessary

Many areas of application of the letter and the output of content require strict adherence to the design rules. A simple example is lists.

Wrong list:

  • __First line;
  • The second line;
  • Third line.

Correct list:

  • First line;
  • Second line;
  • Third line.

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 item should follow immediately after the number. In particular, the text editor MS Word even at the very beginning of its existence proposed to use an indissoluble space (the combination of keys ctrl + "space") to prohibit the gap between the elements of the line.

A non-breaking gap glued together two adjacent words, and it is not at all necessary that they both 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 enjoyed unchanged 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.

Use in headers

The correct title is not torn, but the words in it are not transferred. It is centered or aligned on either side. It is difficult to do without using an indissoluble blank.

In the language of hypertext this will look like this:

7. & nbsp; 5. & nbsp; 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 a 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.

Use in the content page

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 several & nbsp ;.

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.

The encoding 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.

Apply & nbsp; In rows

When processing strings (both on the server and inside the browser) an indissoluble space is not used - it is too expensive to apply instead of one significant symbol "", as many as six "& nbsp;". However, when a string is sent to the output, into 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):

  1. Echo "2 ____ Hello!"; // here "_" stands for "".
  2. Echo "2 & nbsp; Hello!"

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 "Hello!" - From the right.

NBSP - what is it and how to apply it? Important information

Meanwhile, the problem is not at all in 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 want to write the word "director" on the left, and his last name on the right, the vast majority of them form several tabs in a row - quickly and effectively.

Instead of correctly setting the tab stop value and aligning it, the user presses the tab several times and gets the desired effect.

A similar situation is in the markup language HTML. "Привет, Мир, я 3-й раз ошибся..." - будет растянут по всей ширине блока, в которую эта строка была выведена. Many developers do not use special symbols 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 in which this line was Deduced.

If you recode the line in "Hello World, & nbsp; I & nbsp; 3rd & nbsp; times & nbsp; wrong ..." - 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.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.