A comprehensive guide to Markdown syntax

A comprehensive guide to Markdown syntax

Introduction

It is highly likely that you have written markdown text unknowingly, whether it be on online forums like Stackoverflow or on collaborative platforms such as Github or Bitbucket.

Markdown is a simple and easy-to-use markup language that was created by John Gruber in 2004. Today, it is the most widely used markup language in the world.

A markdown file uses the .md or .markdown file extension and can be converted to HTML using processing software like Typora.

In this article, we will explore the syntax of Markdown and how it can be used to format texts.

What is Markdown used for?

Markdown is a plain text format used to create documents that can be easily converted to other formats, including Microsoft Word.

Below are a few places markdown files are used:

  • GitHub README: Markdown is heavily used in the GitHub repository README file to write documentation, API samples, installation guides, and contribution guidelines.

  • Markdown is also used in forums and blog posts.

  • Static site generators also support markdown files.

What can you format with Markdown?

Markdown is a markup language used to format plain text. It allows for the creation of rich text formats, such as bold and italics. Below are examples of what you can format with markdown.

  1. Headings.

  2. Links.

  3. Images.

  4. Blockquotes.

  5. Block of code.

  6. Lists.

  7. Emphasis.

  8. Horizontal rules.

Markdown syntax

Markdown provides different syntaxes to format text richly; below are the syntaxes and how to use them.

  • Headings: Hashes (#) create Markdown headings. One hash is a level one heading, two hashes are level two, and so on until level six headings.
# Heading 1
## Heading 2
### Heading 3 

... 
###### Heading 6
  • Bold: Makes a text stronger and heavier. Surround the text with two asterisks ** to make it stronger.
**Bold**
  • Italics: Use to tilt a text; the text is surrounded by a single underscore ( _ ) character.
_italic_
  • Strikethrough: Strikethrough is a formatting option that is used to cross out text that is no longer valid or relevant. To create a strikethrough, surround the text with double tildes (~~).
~~strikethrough~~
  • Blockquote: This formatting option is used to create a blockquote by placing the greater than character ( > ) at the beginning of the text.
> Blockqoute
  • Code blocks: In Markdown, you can use the code block option to insert a long block of code into your text documents. Depending on the markdown environment, the code block will have different background shading with borders around it to differentiate it from the rest of the text. To create a code block, use three backticks (```) at the beginning and end of the text. You can also specify the language for the code block at the top of the three backticks. For instance:
```Javascript

function foo(){
console.log('bar')
}

```
  • Lists: There are two lists we can create in markdown, just like the regular list in HTML. This list can be created in markdown using asterisks ( * ) for an unordered list or bulleted list, while the ordered list can be created using numbers starting from one (1. ) with a leading period.
1. A Number List 1
2. Number List 2
  1. Nested list 1
  2. Nested list 2

* Bulleted list 1
* Bulleted list 2
  * Nested bulleted list 1
  * Nested Bulleted list 2
  • Links: The syntax for creating an anchor link in a markdown document is [text here](link here). For example:
[Markdown hompage](https://www.markdownguide.org/)
  • Tables: In the Markdown document, tables are created using two characters: pipe ( | ) and dash ( — ). The pipe character creates the table column, while the dash character creates the table row.
| Name     | Email             | 
| ---------|-------------------|
| John Doe | johndoe@gmail.com |
| Jane Doe | janedoe@gmail.com |

Images: Images in a markdown document are represented similarly to links, but images use the exclamation character (!) before the square bracket [].

![markdown logo](https://markdown-here.com/img/icon256.png)

Conclusion

Markdown is a widely used markup language, created by John Gruber in 2004. It is a plain text format used to create documents that can be easily converted to other formats, including Microsoft Word. Markdown files are used in GitHub README files, forums, blog posts, and static site generators. Markdown syntax allows for the creation of rich text formats such as bold and italics, headings, links, images, blockquotes, blocks of code, lists, emphasis, and horizontal rules.

That’s a wrap! If you have thoughts on this, be sure to leave a comment.

If you found this article helpful, like and comment.

You can follow me on Twitter here.