Non-breaking space in CSS

Is it possible to use something like a non-breaking space in CSS? I realise   is an HTML entity.

I have the following CSS but want an extra space either side of the bar symbol.

.menu li:nth-child(n+2)::before {
  content: '| ';

Hi there gandalf458,

have you not considered using a modicum of padding. :pensive:

.menu li:nth-child(n+2)::before { content:'|'; padding:0 10px; }



Yes, I would use padding, but you can do what you are asking. E.g.

content: '|\00a0\00a0';

Strange to admit I hadn’t thought of putting padding round it. I am a numbskull :wink: It works fine. Der!

Thanks @coothead and @ralphm

1 Like

Sorry, but what has this got to do with my question? As you can see I already have an answer, and this is the HTML/CSS forum not the Javascript forum!

If you switch threads after starting to write a reply then the reply can end up being attached to the wrong thread.

Oops! So someone’s missing their reply then…

No, I don’t think so. This member seems to be copying replies from other sites and pasting them here without understanding the question. I have deleted their post, as we do not allow plagiarism (or encourage useless posting like this).


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.