14

I frequently need to create documents that include code snippets and so I wanted to create a style that would format the code snippets in order to make them stand out from the rest of the text.

But when searching for help on how to set a background color, I found nothing.

Following are the steps I followed to accomplish this.

  1. In the Modify Style dialog, click the Format button and select Border...
  2. Select the Shading tab and choose a color in the Fill section.

Anyone else have a better way?

2 Answers 2

7

How to create a style with a background color:

enter image description here

3
  • This is an excellent answer.
    – shrewmouse
    Feb 23, 2022 at 16:07
  • Love the GIF usage, probably much easier to record than writing a whole bunch of steps too!
    – levesque
    Mar 10, 2022 at 15:22
  • In 365, I can format a paragraph to a code font, and Shading. But as soon as I want to create a new Style with that formatting, the Shading disappears.
    – Gauthier
    Jan 16 at 13:37
6

Daniel, you are doing it correctly and the method works for Paragraph or Character styles.

The term Shading is what Word uses, versus Background when it comes to character or paragraphs of text. Shading and Highlight should not be confused either.

In Word, Background usually means the entire document. Highlighting is a text attribute and follows the text when copy/pasted.

Another alternative might be a single cell table (no visible border) that you set the cell to have a shading. The "code cell" could be part of AutoCorrect or AutoText that you pop into the document when need. Then you can simply type or past the code snippet into the code cell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .