Markdown is a lightweight markup language that easily converts to HTML. It is widely used by developers and writers to create documents.
Basic Structure
Headers
Headers are created using the #
symbol followed by a space. The number of #
determines the header level (from 1 to 6).
# Header 1
## Header 2
### Header 3
Paragraphs and Line Breaks
To create a paragraph, simply leave a blank line between blocks of text. To create a line break without starting a new paragraph, you can add two spaces at the end of the line.
This is a paragraph.
This is another paragraph.
With a line break.
Text Formatting
Bold and Italic
To apply bold, use **
or __
, while for italic, use *
or _
.
#### Bold Text
__Bold Text__
*Italic Text*
_Italic Text_
#### Text in _bold and italic_
Strikethrough
You can use ~~
to strikethrough text.
~~Strikethrough Text~~
Lists
Unordered Lists
Unordered lists can be created using *
, +
, or -
.
* Item 1
* Item 2
* Subitem 2.1
* Subitem 2.2
- Item 1
- Item 2
Ordered Lists
For ordered lists, numbers followed by a period are used.
1. First item
2. Second item
1. Subitem
2. Subitem
Links and Images
Links
Links are created using square brackets []
for the text and parentheses ()
for the URL.
[LuisLlamas](https://www.luisllamas.es)
Images
Images are inserted similarly to links, but with an exclamation mark !
at the beginning.
![Alt text](https://www.example.com/image.png)
Code Blocks
Inline Code
To include inline code, use backticks `
.
The command `npm install` installs dependencies.
Code Blocks
For code blocks, use three backticks before and after the block.
```
function greet() {
console.log("Hello, world!");
}
```
Quotes and Notes
Quotes
To create quotes, use the >
symbol at the beginning of the line.
> This is a quote.
Notes
Notes can be added similarly to quotes, but it’s more common to use a block format.
> [Note]: This is an important comment or note.
Tables
Creating Tables
Tables are created using |
for columns and -
for the separation between the header and the body.
| Header 1 | Header 2 |
|-----------|-----------|
| Row 1, Col 1 | Row 1, Col 2 |
| Row 2, Col 1 | Row 2, Col 2 |
Advanced Elements
HTML in Markdown
Markdown allows the inclusion of HTML if more control over formatting is needed.
<p>This is a paragraph in HTML.</p>
Task Lists
To create task lists, square brackets []
are used.
- [x] Task completed
- [ ] Task pending
Footnotes
To create footnotes, the following syntax can be used (depending on the Markdown renderer’s support).
Here is some text[^1].
[^1]: This is the footnote.