How to increase margins around a word except at the edges of a line

Viewed 154

I am using <code> with extra CSS. I'd like to increase the left/right margins around

code {
  margin-left: 10px;
  margin-right: 10px;
}
This word is a <code>reserved</code> word.

That works fine usually, but if the word is at the beginning of a line, it has the awkward extra margin to the left that I don't want. Example:

code {
  margin-left: 10px;
  margin-right: 10px;
}
This word is a <br><code>reserved</code> word.

To be clear, the <br> was only for the above example... I don't know when the <code> is at the beginning of the line, it depends on how it is folded (for a given window width).

CSS word-spacing seems like it could be the fix here, but it appears only to be inter-word spacing, so it doesn't work.

Is there a way to accomplish this using CSS?

2 Answers
Related