David Preston

Musings of an old bloke.

How to Insert a Space Character in HTML

A space, not a non-breaking space, just an ordinary space. Can't be that hard, can it? Well, you would think so. Or I'm rubbish at googling the right thing.

I was working on a project at work, and adding schema.org markup which involved wrapping stuff in <span>s. Which in turn choked my HTML minifier and caused one particular space to disappear. Took me ages to find the solution; how to actually insert an entity for a space.

It's &#32; yup 32, those of us who are old enough remember 32 is the ASCII code for a space. Obvious, eh?

Categories:Web Development