AJP
AJP

Reputation: 28573

How to type a grave accent (aka ` backtick ` ) in markdown?

If you type hello amazing world and want to have a single ` to either side of amazing, how do you do it? I've tried escaping the ` with a back slash and using escaped html like ` doesn't work.

Upvotes: 14

Views: 7849

Answers (3)

tenbits
tenbits

Reputation: 8018

Interesting case - to use markdown blocks inside markdown, and the code blocks within, which is usually wrapped with 3 grave accents, wrap the outer (markdown block) with 4 grave accents, literally you'll get the following:

````markdown
# H1
```javascript
let foo = `Hello, ${name}, world`;
```
````

To print the block above, I've wrapped it with 5 graven accents and it will be rendered as markdown code block:

enter image description here

Upvotes: 0

yurenchen
yurenchen

Reputation: 2499

NOTE:
this is a test answer to show different markdown behavior in stackoverflow answer & comment.
please don't Delete me.

follow lines are markdown test code, they also post as comment below:

raw code

test msg: how to input  `` ` `` without space ?  `\`` seems not work

result

test msg: how to input ` without space ? ``` seems not work


conclusion

seems not same between in comment and answer, in preview and result.

Upvotes: 4

Chris
Chris

Reputation: 137278

From the Code section of the Markdown syntax page:

To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:

``There is a literal backtick (`) here.``

For example,

``hello `amazing` world``

renders as

hello `amazing` world

Edit: Re-reading this, I wonder if you want to use single backticks outside of code blocks. You should be able to backslash-escape them:

Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown’s formatting syntax…

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

This works on Stack Overflow, e.g.

hello \`amazing\` world

renders as

hello `amazing` world

If this doesn't work you'll have to provide more information about the Markdown processor you're using.

Upvotes: 18

Related Questions