Emphasis and Inline Formatting
Formatting words inside a paragraph: italic and bold with asterisks or underscores, strikethrough, inline code, and the rules that decide when a * or _ counts.
Blocks and inlines
A Markdown document is read in two passes. First the renderer finds the blocks: headings, paragraphs, lists, code blocks, quotes. Then it looks inside each block for inline formatting: emphasis, code, links. This page is about that second level, the formatting of words and phrases within a line of text.
# Restart followed by the paragraph
Do **not** restart `nginx`. Inline formatting lives
inside a block and can be nested.
One practical consequence: inline formatting never crosses a block boundary. Bold text that starts in one paragraph cannot end in the next.
Italic and bold
Emphasis is text wrapped in one
* or one _ on each side. It becomes an
<em> element, which browsers show in italics.
Strong emphasis uses two:
**text** or __text__, which becomes
<strong>, shown in bold.
The backup *must* finish before 06:00.
Do **not** restart the database during the backup.
Both _underscores_ and __underscores__ work too.
<p>The backup <em>must</em> finish before 06:00. Do <strong>not</strong> restart the database during the backup. Both <em>underscores</em> and <strong>underscores</strong> work too.</p>
Note that the HTML says em and strong, not
"italic" and "bold". In HTML these elements carry meaning:
<em> is stress that changes the meaning of a
sentence, <strong> marks importance or urgency.
Italic and bold are only how browsers show them by default (see
Text and Semantic Elements).
Combining and nesting
Three markers give both at once, and the two kinds can be nested inside each other:
***Never*** share your password.
**Read the *whole* runbook before you start.**
<p><em><strong>Never</strong></em> share your password. <strong>Read the <em>whole</em> runbook before you start.</strong></p>
Asterisks or underscores?
Both produce the same HTML in ordinary text, so the choice is about consistency. Asterisks have one practical advantage: they also work in the middle of a word (see below). Formatters and teams differ in their preference, so pick one style per document, or let a linter enforce the team's choice (see Linting and Consistent Style).
When a * or _ counts
Not every asterisk is formatting: 2 * 3 is arithmetic,
*.log is a wildcard. To decide, CommonMark looks at
each delimiter run: a sequence
of one or more * characters, or of one or more
_ characters, that is not escaped. What decides whether
a run can open or close emphasis is the character just before it and
the one just after it.
Simplified, the rules are:
- An opening run must be followed by a character that is not whitespace.
- A closing run must be preceded by a character that is not whitespace.
- A run surrounded by spaces on both sides is just text.
Use 2 * 3 cores and match *.log files.
This is ** not bold ** but this is **bold**.
<p>Use 2 * 3 cores and match *.log files. This is ** not bold ** but this is <strong>bold</strong>.</p>
Punctuation makes the rules stricter. A closing run that comes right after punctuation must be followed by whitespace, punctuation or the end of the line. That trips up a very common pattern, the bold label with a colon:
**Note:**The portal restarts at 22:00.
**Note: **The portal restarts at 22:00.
**Note:** The portal restarts at 22:00.
**Note**: The portal restarts at 22:00.
<p>**Note:**The portal restarts at 22:00.</p> <p>**Note: **The portal restarts at 22:00.</p> <p><strong>Note:</strong> The portal restarts at 22:00.</p> <p><strong>Note</strong>: The portal restarts at 22:00.</p>
The first two fail: in the first the closing ** sits
between a colon and a letter, in the second it follows a space. The
last two work. When formatting does not appear, look at the
characters right next to the markers first.
Inside words
The two marker characters behave differently inside a word. An
_ can never open or close emphasis in the middle of a
word; an * can. CommonMark adopted this rule, which
many renderers already followed, because underscores are everywhere
in technical names:
Set max_connections_per_host in the file config_prod_v2.yaml.
Kestrel*Energy*Portal versus Kestrel_Energy_Portal.
<p>Set max_connections_per_host in the file config_prod_v2.yaml. Kestrel<em>Energy</em>Portal versus Kestrel_Energy_Portal.</p>
Strikethrough
Strikethrough draws a line
through text to show that it no longer applies, while keeping it
readable. It is written with two tildes on each side and becomes an
<s> element in markdown-it (some renderers use
<del>, which means "deleted").
Next update at ~~15:00~~ 16:00.
~One tilde~ is not enough in this renderer.
<p>Next update at <s>15:00</s> 16:00.</p> <p>~One tilde~ is not enough in this renderer.</p>
Strikethrough is a good example of how the flavors differ:
- It is not part of CommonMark. It is an extension defined in GitHub Flavored Markdown, and many renderers include it.
- GitHub accepts one or two tildes, markdown-it only two. Use two: they work in both.
-
Slack and Microsoft Teams chat use a single tilde,
~like this~. See Markdown in Chat, Notes and AI Tools.
Inline code
A code span is text between
backticks (`). It becomes a
<code> element, shown in a monospace font, and
everything inside it is taken literally: no emphasis, no links, no
escapes. Use it for anything a reader might type or search for:
commands, file names, paths, setting names, error codes.
Run `systemctl status nginx` and check `/var/log/nginx/error.log`.
In a code span `**this**` and `<b>` stay exactly as typed.
<p>Run <code>systemctl status nginx</code> and check <code>/var/log/nginx/error.log</code>. In a code span <code>**this**</code> and <code><b></code> stay exactly as typed.</p>
Notice the <b> in the HTML: the renderer
escapes the angle brackets so that the browser shows them as
characters instead of reading a tag.
Backticks inside code
To show a backtick inside a code span, wrap it in a longer run of backticks: the span ends at the next run of the same length. When the content starts or ends with a backtick, add a space on both sides; one space at each end is removed.
In Bash, `` echo `hostname` `` prints the host name.
The backtick key looks like this: `` ` ``.
<p>In Bash, <code>echo `hostname`</code> prints the host name. The backtick key looks like this: <code>`</code>.</p>
Logs: C:\Users\mei\*.log
Logs: `C:\Users\mei\*.log`
<p>Logs: C:\Users\mei*.log</p> <p>Logs: <code>C:\Users\mei\*.log</code></p>
Code that spans several lines belongs in a fenced code block, which also supports syntax highlighting. Both are covered on Code: Inline Code and Fenced Code Blocks.
What Markdown has no syntax for
Core Markdown's inline formatting stops at emphasis, strong emphasis, code, links and images. There is no standard syntax for:
- Underline. On the web underlined text is easily mistaken for a link.
- Highlight, color and font size. Markdown describes structure, not appearance.
- Subscript and superscript, such as H₂O or m³. You can often type the Unicode characters directly, as here.
- Keyboard keys, such as Ctrl+C.
Some tools add their own syntax: Obsidian supports
==highlight==, and Discord uses
__text__ for underline, where Markdown makes it bold.
Such syntax only works in that tool. Where raw HTML is allowed, you
can also use HTML elements directly. The example below turns on raw
HTML (data-md-html), which this site otherwise leaves
off:
Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop the script.
The cooling unit uses 4 m<sup>3</sup> of water per hour.
<p>Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop the script. The cooling unit uses 4 m<sup>3</sup> of water per hour.</p>
GitHub, for example, allows these elements. GitHub's documentation
even lists <ins> for underline and
<sub>/<sup> for subscript and
superscript. Many other places strip or escape raw HTML for safety,
as explained on
HTML in Markdown and Safety; check before you rely on it.
Using emphasis well
Emphasis works because it is rare. A few habits keep it useful:
- Bold the one thing that must not be missed, such as "do not reboot" in a runbook step. A page full of bold text has no emphasis left.
- Do not use capitals for emphasis. TEXT IN CAPITALS is harder to read and comes across as shouting.
- Use a code span, not italics, for names that readers type or search for. Italics are for stress and titles.
- Use a heading, not a bold line, for a section title, so that it appears in the outline and can be linked to (see Headings as structure).
A warning in a ticket by Amara Okafor, using each kind of inline formatting for its own job:
**Do not** close this ticket yet. The customer's meter
(`E-4402`) still reports ~~2026-09-30~~ 2026-10-01 as its last
reading date, so the *old* tariff may have been applied.
<p><strong>Do not</strong> close this ticket yet. The customer's meter (<code>E-4402</code>) still reports <s>2026-09-30</s> 2026-10-01 as its last reading date, so the <em>old</em> tariff may have been applied.</p>