Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

How do I escape a back tick within a code block?

This is probably a duplicate, since I'm sure it's a common concern, but I can't find a question that addresses this specifically.

How do I write List'1 with the "1" character still in the code-text format?

share|improve this question
See… – ChrisF Mar 11 '11 at 14:29
with a \ Example: ` – Johannes Kuhn Oct 7 '13 at 9:25
Is there one chasing you? – Rosinante Oct 7 '13 at 15:36
up vote 120 down vote accepted

Use four spaces before your code?


Or use double backticks as in List`1 .

(The code for the above looks like this: ``List`1``)

See, linked to from the formatting question box.

Note: Extra spacing will be necessary if you want to have a backtick at the end of your code, e.g., foo` . This will keep it from consuming the first 2 closing backticks instead of the final two closing backticks.

share|improve this answer
I had to click edit on your post to see what you meant, because I think there is a typo. It appears that you need to delete the backtick after the 1, because as written the formatting is not correct. If you do that I will accept you. – smartcaveman Mar 11 '11 at 14:24
@smartcaveman. Sorry and fixed. I misunderstand you as wanting List'1' for some reason. – Brian Mar 11 '11 at 14:30
The double backtick technique doesn't seem to work on GitHub. – Max Howell Jul 30 '12 at 12:43
@Max: It does now. – Allon Guralnek Aug 19 '12 at 13:28
How do you have two consecutive backticks in inline code? – asmeurer Jun 16 '13 at 16:44
@asmeurer: Wrap your inline code with triple backticks. !``! For triple or higher backticks, you can wrap your inline code with double backticks, rather than quadruple backticks (unless you need both triple and double backticks at different places). !```! vs !``!```! – Brian Jun 16 '13 at 19:09
As mentioned in the other answers to the question, you can simply escape backticks with a backslash `\` for inline formatting. – user163250 Jun 5 '14 at 14:55
Extra spacing also required if you want a backtick at the start of your quote. I just wanted a backtick and nothing else in this answer so used `` ` `` (couldn't work out how to quote this in this comment though!) – Steve Chambers Jan 25 at 21:05

For github, like for displaying a mysql `table_name`, in regular text use \` (backslash backtick)

For showing backticks inside inline codeblocks `table_name` use double backticks with
extra spaces `` `table_name` `` around the inner single backticks.

To show the previous example explanation in an inline codeblock: `` `table_name` ``,
surround the whole in three backticks with extra spaces,
e.g. ``` `` `table_name` `` ```

(head a splode)

share|improve this answer
Thanks for pointing out that extra spaces are required! – CoDEmanX Aug 28 '14 at 20:40
And that continues for any number of backticks. If you are writing about how to use Prism syntax highlighting and want to display three backticks, you need to "escape" them with four backticks and a space. (i.e. ```` ```language_javascript ````) – Jedidja Mar 3 '15 at 18:53

you can use :


when inline it will display List`1

Markdown provides backslash escapes for the following characters:

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark

for example, this:

## \\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \!


\ ` * _ { } [ ] ( ) # + - . !

Escaped codeblock, italics, bold, link, headings and list:

`not codeblock`, *not italics*, **not bold**, [not link](

# not h1

## not h2

### not h3

+ not ul

- not ul

share|improve this answer
I think the escape part of your answer is irrelevant since the OP is asking about how to escape inside an inline code block. – TWiStErRob Jul 16 '15 at 9:44
@TWiStErRob - The escape works in the codeblock. For example, List`1 is achieved using `List\`1`. – Mike Mar 5 at 16:33
@suhail - The escape was the only method I could get to work for this: grep "docker-machine-`uname -s`-`uname -m`", so thanks! – Mike Mar 5 at 16:36
@Mike I'm not even sure what I meant in retrospect, I was probably referencing the second half of the answer, because that's plain text, not code block (notice: no gray background). To clarify: the "put more ticks around the code than you want to escape" part of the answer is awesome, but the backslash-escape sequences are not useful within code blocks as I tried. – TWiStErRob Mar 5 at 16:54

I don't know that this counts as a markdown solution per se... but you can use a <code> tag like so:


... which produces the desired output: List`1

share|improve this answer

Use <code> and HTML character entities instead. This is especially useful in situations where your code is already wrapping things in backticks (e.g., in Swift, enum { case `true` = 1 }).

HTML gives you three ways to specify a character entity for a backtick: &grave;, &#96;, & &#x60;.  The choice is yours.

The way to accomplish example with this technique would be <code>List&#96;1</code>, resulting in List`1.  The markdown for List`List`1 would just be <code>List&#96;List&#96;1</code>.  It's a little messy, but not unbearable if you're used to reading/writing HTML.

While more cumbersome than normal Markdown, this approach is also much more compatible.  Some Markdown parsers don't like backslash-escapes; some will created nested code spans instead of working like @Brian's example; others will do other weird things; but the HTML approach will only fail if the Markdown parser has HTML turned completely off (which is exceedingly rare).

The general approach I take is “If I can't do it with Markdown, or if doing it in Markdown is a complicated mess of repeated symbols and tricks, just drop down to HTML for that use-case.”

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .