Writing & StyleStyle guide

Using Fenced Code Blocks for Longer Code

Using Fenced Code Blocks for Longer Code records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Quick answer

Put longer code snippets or paths in fenced code blocks rather than leaving them as ordinary prose or forcing them into inline code.

Key details

Core Issueusing fenced code blocks for longer code
RegisterMicrosoft Learn technical documentation

Important caveats

Scope Boundary

This is Microsoft Learn Markdown authoring guidance; other publishing systems can use different code-block syntax.

Further guidance

Content

Put longer code snippets or paths in fenced code blocks rather than leaving them as ordinary prose or forcing them into inline code.

Purpose

Keep programmatic or structural text visually consistent and easier for readers to interpret in Microsoft Learn documentation.

Sources and evidence

Sources are shown with the role they play in this guide. Historical or style-sensitive claims are kept within the evidence boundary described above.

  1. Text formatting guidelines — Microsoft Learn Contributor Guide (opens in a new tab)Microsoft · Current Microsoft Learn contributor guidance for Git repository/branch names, code style, package and database names, nonlocalized resource names, fenced code blocks, language tags, headings, and link text.

Related guides

Writing & Style

Using Approved Language Tags in Fenced Code Blocks

Using Approved Language Tags in Fenced Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Writing & Style

Using Triple-Colon Syntax for Referenced Code Snippets

Using Triple-Colon Syntax for Referenced Code Snippets records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Writing & Style

Avoiding Horizontal Scrollbars in Code Blocks

Avoiding Horizontal Scrollbars in Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Writing & Style

Avoiding IDE Screenshots for Code Examples

Avoiding IDE Screenshots for Code Examples records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Writing & Style

Highlighting Key Lines in Code Blocks

Highlighting Key Lines in Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.

Writing & Style

Using Block Includes for Reusable Sections

Using Block Includes for Reusable Sections records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal writing rule.

Writing & Style

Using File-Relative Links for Microsoft Learn Articles

Using File-Relative Links for Microsoft Learn Articles records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal writing rule.

Explore the topic