Monospace

On this page, you’ll learn:

  • How to apply monospace formatting to inline text in AsciiDoc.

  • Where to modify your site’s inline monospace text styling.

Technical content often requires text to be styled in a way that indicates it is a command or source code. Such text is usually emphasized using a fixed-width, i.e., monospace, font.

Inline monospace syntax

A word or phrase is marked as monospace when it is enclosed in a single set of backticks (`word`) (constrained formatting). Bounded characters are marked as monospace when they’re enclosed in a set of double backticks (char``act``ers) (unconstrained formatting).

Bounded characters are characters that are:

  • directly preceded by a non-whitespace character, or

  • directly followed by a non-whitespace character.

Example 1. Monospace inline formatting
A monospace `word`, and a monospace `phrase of text`.

Monospace c``hara``cter``s`` within a word.

You don’t need to use double backticks when an entire word or phrase marked as monospace is directly followed by a common punctuation mark, such as ;, ", and !.

Results

A monospace word, and a monospace phrase of text.

Monospace characters within a word.

Mixing monospace with other formatting

You can add multiple emphasis styles to monospace text as long as the syntax is placed in the correct order.

Example 2. Order of inline formatting syntax
`*_monospace bold italic phrase_*` & ``**__char__**``acter``**__s__**``

Monospace syntax is always the outermost formatting set. Bold syntax (*) must be outside the italic formatting set. Italic syntax (_) is always the innermost formatting set.

Result

monospace bold italic phrase & characters

Site styles

How inline monospace text appears on your site depends on the fonts loaded by your UI and any CSS styles applied to the <code> HTML tag. You can learn more about customizing how monospace text appears in your site in the UI documentation.

Asciidoctor resources