Digital Genetics

How to create a space (&nbsp) using the DOM

by on Sep.01, 2009, under development, Javascript

This is a problem which stumped me when I first started to experiment with creating elements dynamically. A couple of simple methods I have found to work are:

document.createTextNode(String.fromCharCode(160))

or the Unicode equivalent:

document.createTextNode(‘u00a0‘)

Hope this has been able to solve many a headache!

:,

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...