Force html interpret "" as nbsp node text

[[Edited for archive]]

if you want the div to consider that it has a character in it, so you can enter it while contenteditable == true on your parent element, see this link: enter empty divs, and contenteditable = true?

[[Original Question]]

I am trying to insert "  " in my html, but after analysis it prints as "

I get --- <div>" some text"</div>
I want -------> <div>"&nbsp;some text"</div>(where  ; is the text node)

I tried to insert "&nbsp;"and
String.fromCharCode(160)and
document.createTextNode('\u00A0')
but no cigar

Housework experts please enlighten me

change
when I say that I want it to be a &nbsp;node, what I'm trying to say, I want it to  appear in dom in the developer console. I noticed that the behavior " "and &nbsp;is characterized in that the browser does not believe that " "includes any characters

edit2
This is what my house looks like on the developer’s chrome tools [item tabs] for two cases img

just pretend blocks are divs

in the second div report there is innerHTML = "&nbsp;"
whereas the first div does not even have innerHTML property

and I know that you will all be like "what we said!" use "&amp;nbsp;", but when I do this, the browser prints a line "&nbsp;"instead of making non-market space

edit 3 , . contenteditable div , div, . outerHTML, div &nbsp; . , html &nbsp; " ", innerHTML = "&ampnbsp;". , , :

var nbsp = "&ampnbsp;";
string "<div>+nbsp+</div>

... outerHTML, javascript "&ampnbsp;" " "

Maxime Lorant Mathew MacLean ... , .

?

+3
2

.

 <div>"&amp;nbsp;some text"</div> 

: HTML (& nbsp;, & lt;, & gt;, ..)

+2

HTML, & HTML: &amp;:

 &amp;nbsp;     ---> &nbsp;
 &amp;eacute;   ---> &eacute;
 ...
+1

All Articles