I am trying to make something like this text box that has a colored background (gray around my code in this example) in Google Docs.

I would like to put some gray box around my code
without any whitespacing - like this!

But it makes me a white spacing between every line. Is there any solution or plugin for this?


Short answer

Use a single cell table and set the cell background to gray.


  1. Place the insertion cursor in the location of your document
  2. Click on Table > Insert Table > 1 x 1
  3. Click on Table > Table properties Table properties
  4. Set the line size to 0
  5. Set the background color of the cell
  6. Click on the OK button.
  7. Add the text to the table
  1. Open a document in Google Docs, and place the mouse cursor in the place where the text box should be inserted.

  2. From the horizontal toolbar select Insert -> Drawing.

  3. A new drawing window will open. Click the Text box icon (box with a capital T inside) and draw the text box.

  4. Click Fill color icon (paint bucket tilted at a 45° angle) and select the text box fill color.

  5. Select the font and font size. Click More to show more tools and in the new toolbar click the downward pointing arrow on the left side of the toolbar to show a dropdown menu of font sizes. In the screenshot the selected font size is 12.

    enter image description here

  6. Type the required text or copy/paste it into the text box.

  7. Move the text box handles to change the text box dimensions to the right sizes.

  8. Click the blue Save & Close button in the upper right corner.

  9. The text box will be automatically inserted at the place in the document which you selected in Step 1.

  • On the step 1, it's not necessary to type text, just to place the insertion cursor in the place where the drawing should be placed. – Rubén Mar 25 '16 at 14:37
  • While using the Drawing tool does work for this, it also makes your text blurry on HiDPI screens as well as when you print your document. If you're after clear text then (as far as I know) the only way forward is to use a table, as the first answer suggests. But I can't believe Google Docs doesn't have a decent text box option. – Mint Feb 16 at 20:22

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.