Have you ever wondered how these "readme.md" files are written on Github? Or how Blog posts like this are written? Whether you're new or you have been a programmer for a while then you probably have heard of "Markdown" but you probably never had the chance to learn it or you probably know some of its syntaxes but can't quite get the grasp of it. No problem! This tutorial is for anyone who wants to learn Markdown and add a new skill to their belt because it's something everyone should know.
So what's Markdown Exactly❓
Markdown is a lightweight markup language that you can use to add formatting plaintext text documents. Created by John Gruber in 2004 for purpose of readability and ease of use. It can be converted to HTML and other formats. Its file extension usually ends in ".md".
Depending on the application you use, you may not be able to preview the formatted document in real-time. But that’s okay. Markdown syntax is designed to be readable and easy to be used by everyone, so the text in Markdown files can be read even if it isn’t rendered by your application.
What's Markdown used for?🤔
Markdown can be used for everything. People use it to create websites, documents, presentations, email messages, static site generators (Gatsby, etc), forums, and technical documentation. Websites like Reddit and GitHub support Markdown and lots of desktop and web-based applications support it.
Markdown files are a great way because it helps to create beautiful markup without having to build it with code. They are commonly used inside git readme files as documentation but have also grown to be extremely popular on blogging platforms such as hashnode.
Here is the cheat sheet 👇
Headings🔽
Headings will be represented by adding a # symbol before the title. The number of # symbols signifies the number of heading from h1 to h6. So, by adding a single # it will represent a h1 tag, and increasing the no. of # will increase the no. of heading.
# Heading 1 <h1>
## Heading 2 <h2>
### Heading 3 <h3>
#### Heading 4 <h4>
##### Heading 5 <h5>
###### Heading 6 <h6>
Output
Paragraphs🔽
There is no specific syntax used when writing paragraphs in markdown syntax.
this is a paragraph
Output
this is a paragraph
Bold Text🔽
There are many ways to write bold text.
**Bold text** __Bold text__
Output
Bold text Bold text
Italic Text🔽
Similarly to Bold, we can achieve this in many ways.
*Italic text* _Italic text_
Output
Italic text Italic text
Lists🔽
Lists have varying syntax.
To create ordered lists, simply add items with numbers followed by a period. Each list item will need to be on a new line.
1. Ordered list item #1
2. Ordered list item #2
3. Ordered list item #3
Output
- Ordered list item #1
- Ordered list item #2
- Ordered list item #3
To create an unordered list, simply add either a dash (-), asterisk (*), or plus signs (+) in front of your line items.
- Unordered list item #1
- Unordered list item #2
- Unordered list item #3
Output
- Unordered list item #1
- Unordered list item #2
- Unordered list item #3
Links🔽
To create a link, enclose the text you wish to link with square brackets followed by the link in parentheses.
[example.com](https://example.com/)
Output
Images🔽
Images have a similar syntax to links, except they have an exclamation mark in front of the square brackets, followed by the alt text inside the square brackets and the path to the image in parentheses.
![Alt text](./image-1.jpg)
Block Quotes🔽
A block quote can be created by adding a right-facing chevron > in front of a paragraph.
> I am a block quote
Output
I am a block quote
Horizontal rules🔽
There are several ways to add a horizontal rule to a document by either adding three or more asterisks (*), dashes or underscores.
--- _________________ ***
Output
Table🔽
Tables are created using pipes (|) and dashes (-), with colons (:) used to align cell contents.
Column 1 | Column 2 | Column 3
--- | --- | ---
one | two | three
four | five | six
Output
Column 1 | Column 2 | Column 3 |
one | two | three |
four | five | six |
Wrapping up
By now I hope you're confident enough to write your own markdown. Once you get the hang of it, it's easy enough. Apart from being simple, it is also very powerful and widely accepted.
There are more extended syntaxes of Markdown that consist of Footnote, Heading ID, Definition List, Task List, Emoji, Highlight, Subscript, and Superscript. You can check them out here.
If you found this post helpful, share it :)