0% found this document useful (0 votes)
11 views17 pages

GitHub Markdown Basics Guide

This document describes the basic Markdown formatting syntax that can be used for writing and formatting text on GitHub. It covers topics such as headings, text styling, quotes, code formatting, links, images, lists, mentions and more.

Uploaded by

xl1sbzq2o
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views17 pages

GitHub Markdown Basics Guide

This document describes the basic Markdown formatting syntax that can be used for writing and formatting text on GitHub. It covers topics such as headings, text styling, quotes, code formatting, links, images, lists, mentions and more.

Uploaded by

xl1sbzq2o
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic writing and formatting syntax - GitHub Docs [Link]

: Free, Pro, & Team

Get started / Writing on GitHub / Start writing on GitHub / Basic formatting syntax

Create sophisticated formatting for your prose and code on


GitHub with simple syntax.

1 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

Headings

Styling text

Quoting text

Quoting code
Supported color models

Links

Section links

Relative links

Images

Lists

Task lists

Mentioning people and teams


Referencing issues and pull requests

Referencing external resources

Uploading assets

Using emoji

Paragraphs

Footnotes

Alerts

Hiding content with comments

Ignoring Markdown formatting

Disabling Markdown rendering

Further reading

2 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

To create a heading, add one to six # symbols before your heading text. The number of #

you use will determine the hierarchy level and typeface size of the heading.

# A first-level heading
## A second-level heading
### A third-level heading

When you use two or more headings, GitHub automatically generates a table of contents
that you can access by clicking within the file header. Each heading title is listed in the
table of contents and you can click a title to navigate to the selected section.

You can indicate emphasis with bold, italic, strikethrough, subscript, or superscript text in

3 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

bold, italic, strikethrough, subscript,


comment fields and .md files.

Bold ** ** or Command + B (Mac) or **This is bold text**


__ __ Ctrl +B
(Windows/Linux)

Italic * * or _ Command + I (Mac) or _This text is This text is


_ Ctrl +I italicized_ italicized
(Windows/Linux)

Strikethrough ~~ ~~ None ~~This was mistaken This was


text~~ mistaken text

Bold and ** ** and None **This text is


nested italic _ _ _extremely_ extremely
important**

All bold and *** *** None ***All this text is All this text is
italic important*** important

Subscript <sub> None This is a This is a


</sub> <sub>subscript</sub> subscript text
text

Superscript <sup> None This is a This is a


superscript
</sup> <sup>superscript</ text
sup> text

You can quote text with a > .

Text that is not a quote

> Text that is a quote

Quoted text is indented, with a different type color.

4 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

: When viewing a conversation, you can automatically quote text in a comment by highlighting
the text, then typing R . You can quote an entire comment by clicking , then . For
more information about keyboard shortcuts, see "Keyboard shortcuts."

You can call out code or a command within a sentence with single backticks. The text within
the backticks will not be formatted. You can also press the Command + E (Mac) or Ctrl + E
(Windows/Linux) keyboard shortcut to insert the backticks for a code block within a line of
Markdown.

Use `git status` to list all new or modified files that haven't yet been
committed.

To format code or text into its own distinct block, use triple backticks.

Some basic Git commands are:


```
git status
git add
git commit
```

5 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

For more information, see "Creating and highlighting code blocks."

If you are frequently editing code snippets and tables, you may benefit from enabling a
fixed-width font in all comment fields on GitHub. For more information, see "About writing
and formatting on GitHub."

In issues, pull requests, and discussions, you can call out colors within a sentence by
using backticks. A supported color model within backticks will display a visualization of
the color.

The background color is `#ffffff` for light mode and `#000000` for dark mode.

Here are the currently supported color models.

HEX `#RRGGBB` `#0969DA`

RGB `rgb(R,G,B)` `rgb(9, 105, 218)`

HSL `hsl(H,S,L)` `hsl(212, 92%, 45%)`

• A supported color model cannot have any leading or trailing spaces within the backticks.
• The visualization of the color is only supported in issues, pull requests, and discussions.

You can create an inline link by wrapping link text in brackets [ ] and then wrapping the

6 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

You can create an inline link by wrapping link text in brackets [ ] , and then wrapping the
URL in parentheses ( ) . You can also use the keyboard shortcut Command + K to create a
link. When you have text selected, you can paste a URL from your clipboard to automatically
create a link from the selection.

You can also create a Markdown hyperlink by highlighting the text and using the keyboard
shortcut Command + V . If you'd like to replace the text with the link, use the keyboard
shortcut Command + Shift + V .

This site was built using [GitHub Pages]([Link]

: GitHub automatically creates links when valid URLs are written in a comment. For more
information, see "Autolinked references and URLs."

You can link directly to a section in a rendered file by hovering over the section heading to
expose .

You can define relative links and image paths in your rendered files to help readers navigate
to other files in your repository.

7 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

A relative link is a link that is relative to the current file. For example, if you have a README
file in root of your repository, and you have another file in docs/[Link], the
relative link to [Link] in your README might look like this:

[Contribution guidelines for this project](docs/[Link])

GitHub will automatically transform your relative link or image path based on whatever
branch you're currently on, so that the link or path always works. The path of the link will
be relative to the current file. Links starting with / will be relative to the repository
root. You can use all relative link operands, such as ./ and ../ .

Relative links are easier for users who clone your repository. Absolute links may not work
in clones of your repository - we recommend using relative links to refer to other files
within your repository.

You can display an image by adding ! and wrapping the alt text in [ ] . Alt text is a short
text equivalent of the information in the image. Then, wrap the link for the image in
parentheses () .

![Screenshot of a comment on a GitHub issue showing an image, added in the


Markdown, of an Octocat smiling and raising a tentacle.]([Link]
/assets/images/[Link])

8 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

GitHub supports embedding images into your issues, pull requests, discussions, comments
and .md files. You can display an image from your repository, add a link to an online image,
or upload an image. For more information, see "Uploading assets."

: When you want to display an image that is in your repository, use relative links instead of
absolute links.

Here are some examples for using relative links to display an image.

In a .md file on the same branch /assets/images/[Link]

In a .md file on another branch /../main/assets/images/[Link]

In issues, pull requests and comments of ../blob/main/assets/images/[Link]?raw=true


the repository

In a .md file in another repository /../../../../github/docs/blob/main/assets/images/


[Link]

In issues, pull requests and comments of ../../../github/docs/blob/main/assets/images/


another repository [Link]?raw=true

: The last two relative links in the table above will work for images in a private repository only
if the viewer has at least read access to the private repository that contains these images.

For more information, see "Relative Links."

You can specify the theme an image is displayed for in Markdown by using the HTML

9 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

You can specify the theme an image is displayed for in Markdown by using the HTML
<picture> element in combination with the prefers-color-scheme media feature. We
distinguish between light and dark color modes, so there are two options available. You
can use these options to display images optimized for dark or light backgrounds. This is
particularly helpful for transparent PNG images.

For example, the following code displays a sun image for light themes and a moon for dark
themes:

<picture>
<source media="(prefers-color-scheme: dark)" srcset="[Link]
[Link]/25423296/163456776-7f95b81a-f1ed-45f7-
[Link]">
<source media="(prefers-color-scheme: light)" srcset="[Link]
[Link]/25423296/163456779-a8556205-d0a5-45e2-
[Link]">
<img alt="Shows an illustrated sun in light mode and a moon with stars in dark
mode." src="[Link]
[Link]">
</picture>

The old method of specifying images based on the theme, by using a fragment appended to
the URL ( #gh-dark-mode-only or #gh-light-mode-only ), is deprecated and will be removed
in favor of the new method described above.

You can make an unordered list by preceding one or more lines of text with - , * , or + .

- George Washington
* John Adams
+ Thomas Jefferson

To order your list, precede each line with a number.

10 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

1. James Madison
1. James Monroe
1. John Quincy Adams

You can create a nested list by indenting one or more list items below another item.

To create a nested list using the web editor on GitHub or a text editor that uses a
monospaced font, like Visual Studio Code, you can align your list visually. Type space
characters in front of your nested list item until the list marker character ( - or * ) lies
directly below the first character of the text in the item above it.

1. First list item


- First nested list item
- Second nested list item

: In the web-based editor, you can indent or dedent one or more lines of text by first
highlighting the desired lines and then using Tab or Shift + Tab respectively.

To create a nested list in the comment editor on GitHub, which doesn't use a monospaced
font, you can look at the list item immediately above the nested list and count the number
of characters that appear before the content of the item. Then type that number of space
characters in front of the nested list item.

11 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

In this example, you could add a nested list item under the list item 100. First list item
by indenting the nested list item a minimum of five spaces, since there are five characters
( 100 . ) before First list item .

100. First list item


- First nested list item

You can create multiple levels of nested lists using the same method. For example, because
the first nested list item has seven characters ( ␣␣␣␣␣-␣ ) before the nested list content
First nested list item , you would need to indent the second nested list item by at least
two more characters (nine spaces minimum).

100. First list item


- First nested list item
- Second nested list item

For more examples, see the GitHub Flavored Markdown Spec.

To create a task list, preface list items with a hyphen and space followed by [ ] . To mark a
task as complete, use [x] .

- [x] #739
- [ ] [Link]
- [ ] Add delight to the experience when all tasks are complete :tada:

12 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

If a task list item description begins with a parenthesis, you'll need to escape it with \ :

- [ ] \(Optional) Open a followup issue

For more information, see "About task lists."

You can mention a person or team on GitHub by typing @ plus their username or team name.
This will trigger a notification and bring their attention to the conversation. People will
also receive a notification if you edit a comment to mention their username or team name.
For more information about notifications, see "About notifications."

: A person will only be notified about a mention if the person has read access to the
repository and, if the repository is owned by an organization, the person is a member of the
organization.

@github/support What do you think about these updates?

When you mention a parent team, members of its child teams also receive notifications,
simplifying communication with multiple groups of people. For more information, see
"About teams."

Typing an @ symbol will bring up a list of people or teams on a project. The list filters as
you type, so once you find the name of the person or team you are looking for, you can use
the arrow keys to select it and press either tab or enter to complete the name. For teams,
enter the @organization/team-name and all members of that team will get subscribed to
the conversation.

The autocomplete results are restricted to repository collaborators and any other
participants on the thread.

You can bring up a list of suggested issues and pull requests within the repository by
typing # Type the issue or pull request number or title to filter the list, and then press

13 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

typing # . Type the issue or pull request number or title to filter the list, and then press
either tab or enter to complete the highlighted result.

For more information, see "Autolinked references and URLs."

If custom autolink references are configured for a repository, then references to external
resources, like a JIRA issue or Zendesk ticket, convert into shortened links. To know which
autolinks are available in your repository, contact someone with admin permissions to the
repository. For more information, see "Configuring autolinks to reference external
resources."

You can upload assets like images by dragging and dropping, selecting from a file browser,
or pasting. You can upload assets to issues, pull requests, comments, and .md files in your
repository.

You can add emoji to your writing by typing :EMOJICODE: , a colon followed by the name of
the emoji.

@octocat :+1: This PR looks great - it's ready to merge! :shipit:

Typing : will bring up a list of suggested emoji. The list will filter as you type, so once you
find the emoji you're looking for, press or to complete the highlighted result.

For a full list of available emoji and codes, see the Emoji-Cheat-Sheet.

You can create a new paragraph by leaving a blank line between lines of text.

14 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

You can add footnotes to your content by using this bracket syntax:

Here is a simple footnote[^1].

A footnote can also have multiple lines[^2].

[^1]: My reference.
[^2]: To add line breaks within a footnote, prefix new lines with 2 spaces.
This is a second line.

The footnote will render like this:

: The position of a footnote in your Markdown does not influence where the footnote will be
rendered. You can write a footnote right after your reference to the footnote, and the footnote
will still render at the bottom of the Markdown.

Footnotes are not supported in wikis.

: The Markdown syntax used during the beta testing period is now deprecated and will be
removed. You can use the syntax as described in this section.

Alerts are an extension of the blockquote syntax that you can use to emphasize critical
information. On GitHub, they are displayed with distinctive colors and icons to indicate the
importance of the content.

We

15 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

We recommend restricting the use of alerts to one or two per article to avoid overloading
the reader. Consecutive notes should be avoided.

Three types of alert are available. You can add an alert with a special blockquote line that
specifies the alert type, and then add the alert information in a standard blockquote
immediately after.

> [!NOTE]
> Highlights information that users should take into account, even when
skimming.

> [!IMPORTANT]
> Crucial information necessary for users to succeed.

> [!WARNING]
> Critical content demanding immediate user attention due to potential risks.

Here are the rendered alerts.

You can tell GitHub to hide content from the rendered Markdown by placing the content in
an HTML comment.

<!-- This content will not appear in the rendered Markdown -->

You can tell GitHub to ignore (or escape) Markdown formatting by using \ before the
Markdown character.

16 of 17 07/10/23, 23:09
Basic writing and formatting syntax - GitHub Docs [Link]

Let's rename \*our-new-project\* to \*our-old-project\*.

For more information on backslashes, see Daring Fireball's "Markdown Syntax."

: The Markdown formatting will not be ignored in the title of an issue or a pull request.

When viewing a Markdown file, you can click at the top of the file to disable Markdown
rendering and view the file's source instead.

Disabling Markdown rendering enables you to use source view features, such as line
linking, which is not possible when viewing rendered Markdown files.

• GitHub Flavored Markdown Spec


• "About writing and formatting on GitHub"
• "Working with advanced formatting"
• "Quickstart for writing on GitHub"

© 2023 GitHub, Inc. Terms Privacy Status Pricing Expert services Blog

17 of 17 07/10/23, 23:09

You might also like