How to add code block in word online

Have you ever wanted to write a technical article or something similar that required inserting code snippets? have you resorted to copying and pasting and then formatting it most of the time? Here is a tutorial on how to add code block in word online.

To insert a code block into your word document, access the document by logging in to the word online website. Once you have the document open click on the Insert tab and select object. now create a new document and copy and paste the source code.

Check out this tutorial on How to double space in word online?

Steps on how to add code block in word online?

When codes are inserted into a document using just copy and paste there are formatting difficulties users face. This is typical because the formatting and other elements of this text are different.

When text is posted it will show up in a picture-like format where there is a possibility of editing individual elements. But, you will still need to do it manually. If you need a better way of doing it follow these steps.

  • Start by opening a new document in the desktop application of Word. This can be done by opening an existing document and opening a new blank document from the File menu. You could also start by working on the document you have open.
How to add code block in word online
  • Once you have the document open go to the top ribbon and click on the Insert tab.
  • From among the sub-tabs go to the Text section
  • Here you can click on Object.
  • In the dropdown select object again.
  • You will now have a popup window with various options.
How to add code block in word online
  • Make sure you are in the Create new section of the popup menu.
  • In the object type section scroll down till you find Microsoft Word Document.
  • On the right, you will see a Display as icon option. Check the box near it. this way the text inserted will show up as an object or as a group.
  • After you have made the necessary selections click on OK
  • You will now have a blank document in front of you.
  • Minimize the new document and go to the code you would like to copy.
How to add code block in word online
  • It is better to copy the code onto notepad before inserting it into your document.
  • Open notepad or notepad++ from the start menu.
  • now paste the code
  • Once the code is pasted select the text using Ctrl+A and copy it

Read How to add different page numbers in word online

How do you insert a code block in Word?