If you’re not sure where to place this code I highly recommend you read How to create a WordPress plugin for your custom functions. But the editor will automatically removing all spaces(white space and nbsp code) in the. If you dont want to lose your non-breaking spaces by accidentally switching to Visual editor, the only workaround is to disable the Visual editor.
However, with the following PHP filter you can make TinyMCE (also known as “ Classic Editor” - NOT the new Gutenberg editor) automatically create a non-breaking space when using the Ctrl + Shift + Space key combination. It needs double white spaces in the beginning of each paragraph. When using Microsoft Word it’s as easy as typing Ctrl + Shift + Space – but it’s not at easy in an HTML WYSIWYG editor such as in WordPress. They’re commonly used where amounts, such as dollars are separated using a space or when typing a brand name. Related to #3220.A non-breaking space allows you to add a space between two words that prevents an automatic line break (line wrap) at its position. This is not the case of the current editor where non breaking spaces are kept. I have noticed that non breaking spaces are removed by Gutenberg when the post is saved. In that context where line breaks have to be avoided, non breaking spaces are really useful to keep some control over the text. Next time, try putting this bit of code in your functions. They often have widows (words alone on the last line of a paragraph) which is not good from a typographic perspective. If you’ve ever tried to add a non-breaking space in the text editor in WordPress, you know that it disappears once you return to the visual editor and save the page.
line break this serves as a traditional carriage return.In some formats, including HTML, it also prevents consecutive whitespace. Code to Know: Standard WordPress Spacing HTML   non-breaking space typically used to create a wrap or to move text to the next line. In word processing and digital typesetting, a non-breaking space,, also called NBSP, required space, 1 hard space, or fixed space (though it is not of fixed width ), is a space character that prevents an automatic line break at its position. With responsive websites, big titles or text in small columns are difficult to handle. To edit code for specific spacing, start by clicking the Text Editor when in a new post text area.