What is Markdown?
Markdown is a markup language just like HTML. You can also think of it as a text-to-HTML converter tool. It is a way of writing and formatting rich text using plain text formatting syntax. A good example would be this blog itself. I have used Markdown to formulate headings, text formatting, code snippet, bold, italic, links, images etc.
Headings
Heading can be created using #
symbol and add some whitespace after that .
There are 6 headings in total just like HTML doing same functionality only difference is syntax.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
Let's see how it looks:-
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Paragraphs
To create a paragraph use a blank line to separate one or more lines of text or press two times enter to break a line. There is no special syntax of writing paragraphs just write plain text it will make it as a paragraph.
Text formatting styles
Some text styles we can use in markdown are bold , italic, blockquotes, underline, strike-through,subscript,superscript. We will discuss one by one in detail
Bold
To bold the text use 2 asterisks i.e **
before and after the text or you can use 2 underscore __
before and after the words.
This is **bold text**
This is another way of __bold text__
This is how it looks
This is bold text
This is another way of bold text
Italic
We can make a text Italics by enclosing the text in single *
symbol as -> text
or we can also use a single underscore _
symbol before and after the text
This is *Italics text*
This is another way of _italics text_
This is how it looks
This is Italics text
This is another way of italics text
Blockquotes
Blockquotes are used to indicate that the enclosed text is an extended quotation. To create a blockquote we can use the greater than sign > . We can also create a single-line and multi-line blockquote as well as nested blockquote. For nested blockquote use multiple greater than sign >>. We can also add some other text styles like bold and italic in it.
> Many of life’s failures are people who did not realize how close they were to success when they gave up.
>>You only live once, but if you do it right, once is enough.
This is how it looks
Many of life’s failures are people who did not realize how close they were to success when they gave up.
You only live once, but if you do it right, once is enough.
Strikethrough
We can strike through a piece of text in Markdown by enclosing the text inside double ~ symbol as -> text.
The text is ~~stricked through~~
This is how it looks:-
Underlined
We can underline a piece of text in Markdown using the HTML “ins” tag.
<ins>This is an underlined text</ins>
Subscript or Superscript
Superscript or Subscript are characters that are set slighly above or below the normal line of text. We can set them using the “sup” or the “sub” HTML tags respectively.
Subscript <sub>Example.</sub>
Superscript <sup>Example.</sup>
This is how it looks:-
Subscript Example.
Superscript Example.
Syntax Highlighting
We can highlight code syntaxes using markdown by using a backtick(``) symbol before and after the code block. For multiline code formatting, we can also use 3 backticks for the purpose .
Example for single line code:
This is an example of a `code` block.
This is an example of a code
block.
Example for multiline code:
This is an
example of
multiline code block.
We can also add an additional language specifier to enable syntax highlighting.
for example, this is a C++
code so after 3 backticks name of language is mentioned to highlight the syntax.
int x = 10;
cout << x << endl;
Lists
There are 2 types of lists we can add in markdown:- Ordered and unordered lists.
1. Ordered Lists:
An ordered list defines a list of items in which the order of the items matter.
Syntax:
1. First item
2. Second item
3. Third item
Output:-
- First item
- Second item
- Third item
Ordered List with Sublists:
Lists can be nested into sublists to include items that are a part of a longer list. The example below shows how to implement nested unordered lists in markdown.
Syntax:
1. First item
2. Second item
1. second sub item 1
2. Second sub item 2
3. Third item
This is how it looks
- First item
- Second item
- second sub-item 1
- Second sub-item 2
- Third item
2.Unordered lists
Unordered lists are used where numbering does not matter. We can create unordered lists with an asterisk(*), (+), or (-) signs .
With asterisk(*):
* Item 1
* Item 2
* Item 3
With plus(+):
+ Item 1
+ Item 2
+ Item 3
With minus(-):
- Item 1
- Item 2
- Item 3
This is how it looks:-
- Item 1
- Item 2
- Item 3
Nested unordered lists
- Item 1
- Subitem 1
- Subitem 2
- Item 2
- Subitem
- Item 3
This is how it looks:-
Item 1
- Subitem 1
- Subitem 2
- Subitem 1
Item 2
- Subitem
- Item 3
Task lists
To create a task list, preface list items with a hyphen and space followed by [ ]. To mark a task as complete, use [x].
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
It looks like:-
Links
To create a link enclose the link text in square brackets [] e.g[LINK] and then then enclose the URL in open brackets () e.g(google.com)
[Google](https://www.google.co.in/)
It looks like :-
Images
For images the syntax is similar to link only add an exclamation ! sign in starting.
Syntax:-
![Image](https://images.app.goo.gl/feT7QH4KSGux5E726)
It appears:-
Horizontal rules
To create a horizantule line , use three or more asterisks ***
or dashes---
or underscores ___
on an empty line
***
// or
____
// or
----
It looks like :-
Tables
To add a table, use three or more hyphens (---) to create each column’s header, and use pipes (|) to separate each column. For compatibility, you should also add a pipe on either end of the row.
Syntax:-
| Name | Branch |
| ----------- | ---------- |
| Riya sahani | Btech CSE |
| Rahul verma | Btech ECE |
It looks like:-
Name | Branch |
Riya sahani | Btech CSE |
Rahul verma | Btech ECE |
We can also create a markdown table with the HTML <table></table>
tags without headers.
<table>
<tr>
<td>
Name
</td>
<td>
Subject
</td>
<td>
Branch
</td>
</tr>
</table>
It looks like:-
It's all about markdown . Feel free to share your thoughts and make a awesome readme file in your github .