GitHub Markdown

Format README files, issues and pull requests with Markdown: headings, lists, links, images, code blocks, tables and task lists.

Lesson 3 of 30Beginner17 min read

Almost every piece of text you write on GitHub, from a repository's README to an issue, a pull request description or a comment, is written in Markdown. Markdown is a simple way to format text using ordinary characters: a # at the start of a line makes a heading, **two stars** make text bold, and a line starting with - becomes a bullet point.

The beauty of Markdown is that it's readable even before it's formatted. A README.md file looks tidy in a plain text editor, and GitHub turns it into a neat web page with headings, links and highlighted code.

GitHub uses its own extended version called GitHub Flavored Markdown, which adds tables, task lists, automatic links to issues and more. In this lesson you'll learn the syntax you'll use every day and put it together into a README that makes people want to try your project.

Headings, emphasis and paragraphs

Markdown
# Project title
## Installation
### Optional settings

This is **bold**, this is *italic* and this is ~~crossed out~~.
  • One to six # characters make headings of decreasing size. Put a space after them.
  • Leave an empty line between paragraphs. A single line break inside a paragraph is ignored.
  • **text** is bold, *text* is italic, and ~~text~~ draws a line through text.
  • A line starting with > becomes a quote, which is handy when replying to part of a comment.

Code

Wrap short code inside a sentence in single backtick characters, the key usually found above Tab, so that npm start appears in a code font. For longer code, use a fenced code block: three backticks on the line before and after. Add a language name after the opening backticks and GitHub highlights the syntax:

Markdown
```js
const total = price * quantity;
```

Code blocks keep spaces and line breaks exactly as typed, which makes them the right place for commands people should copy, error messages and configuration files.

GitHub extras

You writeYou get
- [ ] Write testsA task list checkbox
#14A link to issue or pull request 14
@samleeA mention that notifies that person
a1b2c3dA link to that commit
A table with pipesA formatted table

Tables use | to separate columns and a row of dashes under the header. Task lists in an issue or pull request show progress, such as "2 of 5 tasks", wherever the issue is listed.

GitHub Markdown Syntax

Markdown quick reference

# Heading 1
## Heading 2
**bold**  *italic*  `code`
- bullet
1. numbered
[link text](https://example.com)
![alt text](image.png)
> quote
- [ ] task  - [x] done task
| Col | Col |
|-----|-----|
| a   | b   |

GitHub Markdown Summary

  • Markdown formats text with plain characters, and GitHub uses it for READMEs, issues, PRs and comments.
  • # makes headings, ** bold, * italic, - bullet lists and 1. numbered lists.
  • Links are [text](url); images are ![alt text](path).
  • Fenced code blocks with a language name get syntax highlighting.
  • GitHub adds tables, task lists, @mentions and automatic #issue links.

GitHub Markdown Examples

Each example shows the code, the output it produces and what each part does.

Example 1

A clear README

Markdown
# Recipe Box

A small website for saving and searching your favourite recipes.

![Recipe Box home page](images/screenshot.png)

## Features
- Search recipes by ingredient
- Save favourites in your browser
- Works on phones and tablets

## Getting started
1. Clone the repository
2. Open `index.html` in your browser

## Built with
HTML, CSS and JavaScript.
Output
Recipe Box                                  (large heading)
A small website for saving and searching your favourite recipes.
[screenshot image]
Features                                    (section heading)
  • Search recipes by ingredient
  • Save favourites in your browser
  • Works on phones and tablets
Getting started
  1. Clone the repository
  2. Open index.html in your browser
Built with
HTML, CSS and JavaScript.
Line-by-line explanation
  1. Line 1The project name as the only top-level heading.
  2. Line 3One sentence saying what the project is.
  3. Line 5A screenshot shows the result instantly. The alt text describes it.
  4. Lines 7 to 10A short feature list.
  5. Lines 12 to 14Numbered steps for setup.
Example 2

A code block and a table

Markdown
Run the tests with:

```bash
npm test
```

| Command | What it does |
|---------|--------------|
| `npm start` | Start the site |
| `npm test` | Run the tests |
Output
Run the tests with:
┌──────────────────────────┐
│ npm test                 │   (grey box, highlighted)
└──────────────────────────┘
Command      What it does
npm start    Start the site
npm test     Run the tests
Line-by-line explanation
  1. Lines 3 to 5A fenced code block labelled bash.
  2. Lines 7 to 10The dashes row separates the header from the data. Columns don't need to line up perfectly.
Example 3

A pull request description

Markdown
## What changed
Adds a search box to the header. Closes #14

## Checklist
- [x] Works on mobile
- [x] Added alt text
- [ ] Updated the README

@priya could you check the colours?
Output
What changed
Adds a search box to the header. Closes #14   (#14 becomes a link)
Checklist
  ☑ Works on mobile
  ☑ Added alt text
  ☐ Updated the README
@priya could you check the colours?          (Priya is notified)
Line-by-line explanation
  1. Line 2Closes #14 links the issue and closes it when the PR merges.
  2. Lines 5 to 7Task list items with [x] appear ticked.
  3. Line 9The mention sends Priya a notification.

Common GitHub Markdown Mistakes

No space after the hash

Don't
#Installation
Do
# Installation

Lists without a blank line before them

Don't
Features:
- Search
- Favourites
Do
Features:

- Search
- Favourites

Some Markdown viewers join the list onto the paragraph without the blank line. Adding it always works.

Images with no alt text

Don't
![](images/screenshot.png)
Do
![Recipe Box home page showing the search box](images/screenshot.png)

GitHub Markdown in Real Projects

Markdown everywhere

A project's README is its front door: it's the first thing visitors see, and a clear one with a screenshot and setup steps can make the difference between someone trying your project and closing the tab. Beyond GitHub, Markdown is used in documentation sites, note-taking apps, chat tools and many blogging platforms, so the syntax pays off far beyond this course.

GitHub Markdown FAQ

How do I add a line break without starting a new paragraph?

End the line with a backslash \ or with two spaces before pressing Enter. The backslash is easier to see when you edit the file later. You can also use the HTML tag <br>, which GitHub allows in Markdown.

How do I make a collapsible section in GitHub Markdown?

Use the HTML <details> and <summary> tags. The text inside <summary> is shown as a clickable heading, and everything else inside <details> stays hidden until someone clicks it. Leave a blank line after </summary> so the Markdown inside is formatted.

How do I show a character like * or # without formatting it?

Put a backslash in front of it: \*not italic\* shows the asterisks as written. This works for Markdown's special characters, including #, _, [ and backticks. Inside inline code or a code block, nothing is formatted, so you don't need backslashes there.

How do I add a note or warning box in a GitHub README?

Use an alert: a blockquote whose first line is > [!NOTE], followed by more > lines with the text. GitHub supports NOTE, TIP, IMPORTANT, WARNING and CAUTION, each with its own colour and icon. Other Markdown viewers show it as an ordinary quote.

Can GitHub render diagrams from Markdown?

Yes. Write a fenced code block with the language set to mermaid and Mermaid syntax inside, and GitHub draws a diagram such as a flowchart or sequence diagram. It works in README files, issues, pull requests and wikis.

GitHub Markdown Exercises

Answer each one and check it instantly. If you get stuck, open the hint before the answer.

Fill in the blankseasy

Complete the Markdown for a second-level heading.

 Installation
Multiple choiceeasy

Which Markdown makes text bold?

Multiple choicemedium

Which line is a correct Markdown link?

Predict the outputmedium

What does - [ ] Write tests show in a GitHub issue?

Multiple choicehard

How do you get syntax highlighting for a block of Python code?

GitHub Markdown Quiz

5 questions to check what you learned.

  1. What file name does GitHub show on a repository's front page?

    • README.md
    • index.html
    • home.md
    • about.txt
  2. How do you make an image in Markdown?

  3. What happens when you write @samlee in a comment?

    • Nothing
    • Sam gets a notification and the name links to their profile
    • Sam is added as a collaborator
    • The comment is sent by email only
  4. Why should screenshots in a README have alt text?

    • It makes the image load faster
    • Screen readers read it aloud, and it shows if the image fails to load
    • GitHub requires it to publish
    • It changes the image size
  5. Your bullet list appears glued to the previous paragraph. What's the most likely fix?

    • Add an empty line before the list
    • Use * instead of -
    • Put each item in quotes
    • Indent the whole list by eight spaces