Victoria M. answered 2h
Tutor
4.9
(173)
Over 20 years of corporate/academic experience with Microsoft Word
Yes, this can be done using Styles in Word! The key is to use paragraph shading instead of text highlighting, which only colors behind the characters. Here's how to create a reusable Quick Style for code blocks:
🧱 Step-by-Step: Create a Code Snippet Style in Word
1. Format a Sample Code Block
- Type or paste a sample code snippet into your document.
- Select the entire block.
- Go to the Home tab and:
- Set the Font to
Consolas
(or another monospaced font like Courier New). - Set the Font Size (e.g., 10 or 11 pt).
- Click the Paragraph dialog launcher (small arrow in the bottom-right of the Paragraph group).
- Under Indents and Spacing, set Spacing Before/After to 6 pt (optional).
- Under Shading (in the Borders and Shading dialog), choose a gray fill color (e.g., light gray).
- Click OK.
2. Create a New Style
- With the formatted block still selected, go to the Styles group on the Home tab.
- Click the More button (downward arrow with a line) to expand the Styles pane.
- Click “Create a Style”.
- Name it something like Code Snippet Box.
- Click Modify.
- Ensure “Style type” is set to Paragraph.
- Check “Add to the Styles gallery”.
- Click New documents based on this template if you want it available in future docs.
- Click OK.
3. Apply Your Style Anywhere
- Now, whenever you want to format a code block:
- Select the text.
- Click your Code Snippet Box style from the Styles gallery.
- Done!
✅ Bonus Tips
- You can also add a border around the paragraph for extra visual clarity.
- If you want inline code formatting (e.g., within a sentence), create a Character Style instead.

Victoria M.
2h