1

For

<myDIV id="myInput" contenteditable="true"></myDIV>

I want to set "abcdefg " with a space behind.

Doing this

var myInputDIV = document.getElementById("myInput");
myInputDIV.innerHTML = "abcdefg "; //does not work
myInputDIV.textContent = "abcdefg "; //does not work

How to make sure that I get the space behind? Currently, the string shown in the div is just "abcdefg", without the space.

Thanks.

theAnonymous
  • 1,701
  • 2
  • 28
  • 62

2 Answers2

2

You can add space in html in on of the following ways:

  • add &nbsp; as a space sign
  • add &#160; as a space sign
malutki5200
  • 1,092
  • 7
  • 15
1

Types of Spaces in HTML

Creates four spaces between the text- &emsp;

Creates two spaces between the text - &ensp;

Creates a regular space between the text - &nbsp;

creates a narrow space ( similar to regular space but slight different) - &thinsp;

spacing between sentences - </br>

This link might help you. Check out the link here

SENTENCE SPACING IN HTML AND CSS

Vivek Budithi
  • 562
  • 4
  • 14