Question

I have a problem, but maybe this is not a problem actually! Why below HTML markup is generating a result which seems to be incorrect even using Standard Fonts like Arial?

<span>سلام</span><span>خداحافظ</span>

سلامخداحافظ

Above output shouldn't be this? (ignore space used for simulation)

سلام خداحافظ

Also i have used margin for a tag but same problem. Thanks in advance ;)

Was it helpful?

Solution

HTML elements do not necessarily break words. There are many legitimate reasons for that.

For instance, you might want to put emphasis on a letter in medial form by wrapping it in a <strong> or <em> element. If that element was considered as a single word, the letter would switch to its isolated form, which would probably not be the effect you're looking for.

Inserting either a non-breaking space (&nbsp;) or a zero-width non-breaking space (&#8203;) between the <span> elements fixes your problem.

You can see the results in this fiddle.

OTHER TIPS

As i know span tag doesnt have href. I assume that u mean a tag.

u can use a space character between a tags to get desired result:

<a href="#">سلام</a>&nbsp;<a href="#">خداحافظ</a>

You can also enter an space between the to tags like. there is no need to use html codes:

<a href="#">سلام</a> <a href="#">خداحافظ</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top