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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.