JChlip
JChlip

Reputation: 121

HTML Get rid of white space collapsing

If you write this:

a
b

it will normally render as "a b". I want it to render as "ab". Any thoughts?

Upvotes: 2

Views: 1195

Answers (3)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201538

This is not about white space collapsing, since there is just a line break between the characters. Collapsing is about multiple consecutive whitespace being treated as one space.

There is no way in HTML to say that normal HTML whitespace rules be not applied in the sense of ignoring a line break.

In CSS, you could set e.g. word-spacing: -0.25em, though 0.25em is just a rough approximation of the width of a space.

To make “a” and “b” rendered without a space between them, write them as “ab”.

Upvotes: 0

lededje
lededje

Reputation: 1869

Nope sorry, you can't

If there is one character deemed to be white space (either a tab, space or line break) then a space will be added. You can use javascript to remove the spaces but it's not suggested. What ever is printing it out should be taking care of that for you.

What platform are you using, we may be able to help better if we knew the circumstances.

Upvotes: 1

Brian Ustas
Brian Ustas

Reputation: 65499

You could add a comment:

a<!--
-->b​​​​​​​​​​​​​​​​​​​​​​​​​

Upvotes: 0

Related Questions