Why do I lose spaces after italics in my HTML blog posts?
July 18, 2013 5:02 PM   Subscribe

Why do my spaces disappear after I close an italics tag in HTML? I write blog posts that get published on a custom CMS that works more or less like Moveable Type, WordPress, or TypePad: You can type in a box and then use the interface's buttons to bold, italicize, or make links, or you can paste in your own HTML-coded text. I like to type up my posts with my own code, meaning I type the <whatever> </whatever> in with my prose. This works great, except I sometimes lose a space after closing an italics tag, even though it's typed in correctly. For the life of me I cannot figure out why the CMS seems to eat those spaces. I use em, not i, if that matters.

It's not my code — I write in a text editor and can go back and check if I simply left out the space, and I haven't. It does not happen every time, and it doesn't happen with every instance of a particular word, so I can't even keep an eye out for that.

Has anyone ever dealt with this? Any idea what might be causing it, or what a good work-around is, other than just keeping an eye out for it when I'm editing? (Which I do, obviously.)
posted by Charity Garfein to Computers & Internet (13 answers total) 1 user marked this as a favorite
Obvious question: Is there a space there in the code? Is the space inside the em tag or after? Are your code editor an the CMS using the same character encoding?
posted by humboldt32 at 5:54 PM on July 18, 2013

Response by poster: The space is after the em tag. It works correctly about 80 percent of the time.
posted by Charity Garfein at 6:05 PM on July 18, 2013

Try explicitly typing &nbsp; where you want your space to appear.
posted by jozxyqk at 6:13 PM on July 18, 2013

If you're saying what I think you're saying, the issue is that the italicized text is more or less leaning into the space, thus making it look like it's not there, the degree of which depends on the font you're using.
posted by 2oh1 at 6:50 PM on July 18, 2013 [1 favorite]

I've seen things like this show up when people use odd sanitizing routines. If that's the cause there's nothing you can do but find a case and report it to the CMS makers so they fix it.
posted by phearlez at 6:51 PM on July 18, 2013 [1 favorite]

Response by poster: Not to threadsit, but it's not lousy kerning. The space really is vanishing.
posted by Charity Garfein at 7:00 PM on July 18, 2013

If you view the source code of the rendered page, what do you see? Is your space there?
posted by sbutler at 7:23 PM on July 18, 2013 [1 favorite]

As jozxyqk notes, the non-breaking space can be used to force printing a space (or to prevent a line-break, hence its name).

What's happening is the web's by-default enforcement of the single-space after punctuation rule. Yes, that space is vanishing -- your browser converts any spaces to just one space. It's a feature -- but there's a hack, see above.
posted by Rash at 10:43 PM on July 18, 2013

But come to think of it, I have noticed recently the italics of <em>-tagged strings leaning so far into the trailing space that it's negated. But I've thought that's a font issue.
posted by Rash at 10:56 PM on July 18, 2013

Do you see the same behavior in all browsers? Also, per the HTML spec contiguous whitespace is condensed into a single space (unless added as an entity - &nbsp; or & #160;).
posted by askmehow at 4:13 AM on July 19, 2013

What phearlez said-- I support a CMS as part of my job, and it sounds like someone modified the publishing routine to clean up tags, probably in response to an early user/tester doing something wrong consistently-- and it has unintended overreach.

Do you have contact with the developers or a dedicated support person? Your best be is to tell them about it because it doesn't sound like something you're doing, and the only way you're going to be able to address it yourself is by including the aforementioned &nbsp; .
posted by Mayor Curley at 4:47 AM on July 19, 2013

I have this problem whenever Wordpress transitions from "html" mode (which is the only mode I'll work in) to "visual" mode (which is stupid and shouldn't exist). The only artifact it leaves when I take text from there is a disappearing of the space after either italics or links. (Hence why I rarely do this, unless I need WP to translate embedded links. STUPID EMBEDDED LINKS, how I hate writers who do that.)

So I suspect part of what's happening is the way the CMS is set up to save. Someone needs to look into that and tinker with it, essentially.

And no, the answer isn't hand-adding a non-breaking space. I would actually stop writing if that became a necessary part of my workflow.
posted by RJ Reynolds at 5:05 AM on July 19, 2013

Response by poster: Yeah, what RJ Reynolds is describing is exactly what's happening. At least I am not totally alone in my struggles.
posted by Charity Garfein at 7:37 AM on July 19, 2013

« Older Quick, I need kids shows about going potty on...   |   State Constitutions Newer »
This thread is closed to new comments.