space after word can be given a bg color (space before word can)

I want to easily create leading and trailing space with the same background of a word.

(In the image, I want 1 instead of 2)

If I insert a space before the word, the background is the same as the word, but if I insert a space after the word a blank bg is created.

The clumsy workaround I use is to add any character after the word and color de character as the bg. It works until I save and open and colors get different shades and mess up.

Is there an solution?

Can I propose as an improvent that inserting immediately space after a word produces the same result as before a word?

Thanks
image description

I assume that you apply manually the background colour and this explains why you bump into this range extension/reduction problem. The correct way to deal with such situation is with styles, specifically character styles.

Why do you background colour a word (and its surrounding space)? What do you want to convey to the reader? Answers to these questions define a semantic meaning for the word (and more generally any sequence satisfying the definintion).

In such a situation, create a character style, give a mnemotechnic name and mark up the sequences. The marked range is precisely controlled; include the needed spaces in it.

The advantage of this method is the ability to change the background, highlight, font, sier, weight, … from the style definition and changes are immediately effective on all occurrences.

I let you explore the built-in help (and downloadable free manual) to learn how to configure styles.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

…but if I insert a space after the word a blank bg is created.

That’s totally normal. Even if you change the font or font size of a word and you place the cursor directly after the word, it continues writing as before. This is not a mistake.
I suggest you first write your text and mark afterwards the word that should be formatted. For formatting, I would create a style.

image description

image description

Thanks to both. Obviously I use this type of highlighted text all the time for headings. What I have seen after your answers is that the background is applied as expected (both leading and traling spaces are highlighted) in paragraphs, headings, with single words or any other style BUT NOT within TABLE CELLS where I use different colors for schedules, charts, etc. and where the highlighted word needs a word following it. If you delete the word that follows, the highlighted space or spaces goes with it.
I checked that the style in both cases is the predefined one.

As for styles I don’t know how they work (I know I should) and never used them / needed them with MS Word either.

Thanks.

For styles you can read the “Writer Guide”.

You can also apply a style to the characters in a table.