Languages
[Edit]
EN

Markdown - how to create code lines (syntax highlighting - github, dev.to, stackoverflow)

0 points
Created by:
Elias999
669

In this article, we would like to show you how to create code lines in markdown.

Below examples present how to create:

  • Inline code
  • Code blocks¬†with highlighting¬†

1. Creating inline code

To create inline code in markdown you need to wrap your code into backticks ``.

Example:

`var result = 1`

Result:

Markdown - inline code example (markdown)
Markdown - inline code example

2. Code blocks with highlighting 

To create a code block with highlighting you need to wrap your code with three backticks (```) and specify the programming language in the first line.

Example:

```javascript

const data = {
    user: {
        username: 'john',
        password: 'Secret$$'
    }
};
```

Result from github.com:

Markdown - highlighted JavaScript code example on github.com
Markdown - highlighted JavaScript code example on github.com

Result from dev.to:

Markdown - highlighted JavaScript code example on dev.to
Markdown - highlighted JavaScript code example on dev.to

Result from stackoverflow.com:

Markdown - highlighted JavaScript code example on stackoverflow.com
Markdown - highlighted JavaScript code example on stackoverflow.com

References

Alternative titles

  1. Markdown - how to create inline code and highlighted code blocks
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Markdown

Native Advertising
ūüöÄ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

‚̧ԳŹūüíĽ ūüôā

Join