Links and images

Markdown · Essentials · 8 min

Docs are a web of links, and good alt text makes images accessible.

An inline link is [link text](url), optionally with a title in quotes: [docs](https://example.com "Read the docs"). The URL can be relative, which is how you link between files in a repository: [setup guide](docs/setup.md).

An image is the same with a leading !: ![alt text](images/diagram.png). The alt text is shown when the image can't load and read by screen readers, so describe what the image shows rather than writing "image". Markdown has no syntax for image size; use an HTML <img> tag with width when you need it.

Autolinks: wrap a URL or email in angle brackets, <https://example.com>. GitHub Flavored Markdown also links bare www. and https:// URLs automatically.

Links to headings use the anchor the renderer generates: on GitHub, ## Getting started becomes #getting-started (lower case, spaces to hyphens, most punctuation removed). So [see below](#getting-started) jumps there.

Wrap a link around an image to make the image clickable: [![build status](badge.svg)](https://ci.example.com), the pattern behind README badges.

URLs with spaces or parentheses should be encoded (%20) or wrapped in angle brackets: [file](<my file.md>).

Example

See the [installation guide](docs/install.md) or the
[website](https://example.com "Project homepage").

Jump to [Getting started](#getting-started).

![Architecture: the API talks to Postgres and Redis](docs/arch.png)

[![CI status](https://ci.example.com/badge.svg)](https://ci.example.com/project)

Contact: <team@example.com> or <https://example.com/support>

<img src="docs/logo.png" alt="Project logo" width="120">

## Getting started

Remember

  • [text](url "title") for links, ![alt](src) for images
  • Relative URLs link files within a repository; #slug links headings
  • Write meaningful alt text; use <img width> when size matters

Watch out for

  • Putting a space between ] and ( as in [text] (url), which breaks the link.

Check yourself

  1. How do you make a clickable badge image that links to a CI page?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: spec.commonmark.org/0.31.2/#links