Asked • 03/19/19

Create a Microsoft Word Quick Style for a Code Snippet Box?

I'm trying to format some text in my Word doc to have a background color of gray. This is for me to have a Quick Style to apply this formatting. I want to use a monospaced font, like Consolas, and have the entire block have a gray background. When I highlight text and set the background color though, it only set the color behind the text, not the area rectangular area the text sits on within the doc layout. How can I do this?

1 Expert Answer

By:

Victoria M.

tutor
🍎 Microsoft Word on Mac: Create a Code Snippet Quick Style ✅ Goal: Create a reusable style that uses a monospaced font (like Consolas), a gray background, and consistent spacing—perfect for formatting code blocks. 🧱 Step-by-Step Instructions 1. Format a Sample Code Block Open your Word document. Type or paste a sample code snippet. Select the text block. In the Home tab: Set the Font to Consolas (or Courier New if Consolas isn’t available). Set the Font Size (e.g., 10 or 11 pt). With the text still selected, go to: Format > Paragraph. Set Spacing Before/After to 6 pt (optional). Click Borders and Shading (bottom left of the Paragraph dialog). Under the Shading tab, choose a gray fill color (not “Highlight”—this is key!). Click OK. 2. Create a New Style With the formatted block still selected: Go to the Home tab. Click the Styles Pane button (usually a small icon near the top right of the Styles group). Click the New Style button (plus sign). In the dialog: Name your style (e.g., “Code Snippet Box”). Set Style Type to Paragraph. Check “Add to Quick Style list”. Click OK. 3. Apply Your Style Anywhere Select any block of code. Click your new style from the Styles gallery. Done! 💡 Extra Tips Want a border around your code block? In Borders and Shading, add a box border. For inline code (within a sentence), create a Character Style instead.
Report

2h

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.