Markdown Cheat Sheet – GitHub
Last Updated :
02 Sep, 2024
Markdown is a lightweight markup language that allows you to format text using plain text syntax. It is widely used on GitHub for README files, comments, issues, and pull requests, used to create formatted documents without requiring extensive knowledge of HTML or other web technologies.
In this article, we will guide you through the basics and advanced features of GitHub Markdown, helping you use its full potential for your projects.
What is Markdown?
Markdown is a plain text formatting syntax, designed to be easy to read and write. It allows you to format documents using simple syntax that converts to HTML behind the scenes. GitHub has adopted its version called GitHub Flavored Markdown (GFM), which includes additional features designed according to the platform’s needs, such as syntax highlighting for code blocks, tables, and task lists.
Why Use Markdown on GitHub?
Whether you want to update README.md files, write documentation, pull request descriptions, understand projects on GitHub or contribute to any open-source projects understanding markdown is important. Later, It can be easily converted to HTML, providing you with the tools needed for creating visually compelling and well-structured documents.
Now Let’s discuss some Text Formatting Techniques
Basic Text Formatting
Markdown supports basic text formatting to make your content more readable and visually appealing.
Headers are used to define sections and subsections in your document. It is created by using the ‘#’ symbol, a number of ‘#’ symbols indicating the hierarchical level. ‘#’ for Heading level 1, ‘## ‘ for Heading level 2, followed by the header text and so on.
Example:

Headers in Markdown
2. Emphasis
For emphasizing text by either Italics or bold .
- Bold and Italic Text:- For italics, you can use asterisks ‘*’ or underscore ‘-‘ around the text. For bold you can use double asterisks ‘**’ or double underscores ‘__’ around the text. you can also combine emphasis for both bold and italics by using triple asterisks ‘***’ or underscores ‘___’ around the text.

Bold and Italic Text
- Strikethrough:- For strikethrough, you can use double tildes ‘~~’ around the text.

Strikethrough
3. Blockquotes
Blockquotes are used to quote text.. This is used for highlighting Important Information or quotes. Begin the line with ‘>’ symbol.

Blockquotes
Working with Lists
Lists are useful for organizing information in a structured format.
1. Unordered lists
Unordered Lists use asterisks ‘*’ , dashes ‘-‘ or plus ‘+’ .
Example

Unordered lists
2. Ordered Lists
Ordered Lists use numbers.

Ordered Lists
3. Nested Lists
For creating a nested list ,you can use combination of ordered and unordered lists.

Nested Lists
Working with code and syntax highlighting
- Inline Code: Use backticks `inline code`.
- Code Blocks: Use triple backticks for Code Blocks or indent the code with four spaces.
- Syntax Highlighting for various Languages:
For syntax highlighting you can also specify the programming language.
Example

Working with code and syntax highlighting
Links and URLs
1. Creating Inline Links
These are created using square brackets ‘[ ]’ followed by the parenthesis ‘( )’ .
[Link Text](URL)

Creating Inline Links
2. Reference Links
These are created using square brackets and define the reference elsewhere.
[Link Text][Reference]

Reference Links
3. Linking to Headings and Sections
For linking to the headings or sections, you can use id’s.
Markdown automatically generates the id’s for the headings which can be used in the links. we can do this by
- Replace spaces with Hyphens
- Convert the heading to lowercase
- Remove special characters.
Syntax:
[Link Text][#heading-id]
Example

Linking to Headings and Sections
Images
Images are similar to links but begin with exclamation mark ‘!’ at the beginning.
- Embedding Images: Embed the image using this syntax. Alt text is the description of the image that is displayed when the image is not displayed followed by the URL of the image.

Embedding Images
- Resizing Images in Markdown: For resizing the image ,you cannot use markdown directly but you can use HTML within markdown.

Resizing Images in Markdown
- Linking Images: For making the image a clickable link ,you can use the following syntax.
[](link-url)
Tables
Tables in Markdown allow you to present data in a structured format.
- Creating Simple Tables: Pipes’|’ and dashes’-‘ are used for creating tables. Pipes are used to separate columns and dashes are used to create header rows.

Creating Simple Tables
- Aligning Table Content: To align the content within the table columns, you can use the colon(‘:’) in the header row:-
- Left-aligned: `:—-`
- Center-aligned: `:—:`
- Right-aligned: `—-`
Example:

Aligning Table Content
Advanced Text Formatting
Markdown on GitHub supports more advanced formatting options.
- Task Lists: Simple start a list with -[ ] for Incomplete task or unchecked items and -[x] for complete task or checked items.

Task Lists
- Emojis: In, markdown you can use emoji by typing the corresponding shortcode wrapped in colons.

Emojis
This will render as: I am feeling ? today!
- Mentions(@username) and References(#issue): In GitHub, you can mention users or reference issues directly in markdown.
- Mentions: Use ‘@username’ to mention a specific user.
- References: Use ‘#issue-number’ to reference an issue or pull request.
Using HTML in Markdown
Markdown supports basic formatting ,but when you need more control over the layouts you can use html tags within markdown.

Using HTML in Markdown
- Combining HTML and Markdown: You can combine HTML and Markdown together as well for better formatting.

Combining HTML and Markdown
Footnotes are used for additional information or references to your text without interrupting the flow of main text .
- Create the footnote reference: Inside a square bracket, place a carat(^) followed by identifier(number or word) where you want the footnote reference to appear in the text.
- Define the Footnote: At the end, you can define the footnote with the same identifier inside the square brackets followed by colon(:) ,and then the footnote text.

Using Footnotes in GitHub Markdown
Special GitHub Features in Markdown
- GFM(GitHub Flavored Markdown) Enhancements: It extends basic Markdown with additional features.
- Task Lists
- Tables
- Strikethrough
- Autolinked URLs
- Table of Contents: Markdown does not support automatic Table of content generation but you can manually create one by linking to headers.

Table of Contents
- Autolinked References and URLs: GitHub automatically converts some text patterns into clickable links. Issue or References and URLs.

Markdown Cheat Sheet – GitHub
Please Login to comment...