MarkdownPaper Open reader

Guide

How to add comments in Markdown

To write a comment that does not show on the page, use an HTML comment: <!-- your note -->. It stays in the file for anyone editing it, and disappears when the file is shown as a page.

You write

Visible text.

<!-- A note for the next person who edits this file. -->

More visible text.

You see

Visible text.

More visible text.

On this page

Comment out a block

An HTML comment can cover many lines, including Markdown you want to hide for now without deleting it.

You write

Visible.

<!--
## A section not ready yet

- Draft point one
- Draft point two
-->

Also visible.

You see

Visible.

Also visible.

The [//]: # trick

A link definition with no link using it is never shown, so some people write comments as one. It works in most apps, but only for a single line, and the text must sit inside the brackets.

You write

[//]: # (This line is hidden too.)

Visible text.

You see

Visible text.

The HTML comment is clearer and more widely understood, so use it unless an app removes HTML.

Comments are not secret

A comment is hidden on the page, but it is still in the file. Anyone who opens the file, or views the source of a web page made from it, can read it. Never put passwords or private notes in a comment.

Where comments are hidden

App<!-- -->[//]: #
GitHubHiddenHidden
MarkdownPaperHiddenHidden
Apps without HTMLMay showHidden

Common problems

  • The comment shows on the page. The closing --> is missing or mistyped. Everything after an unclosed comment can vanish too, so check for it first.
  • A comment inside code shows. That is expected: code blocks show everything as typed.

Questions

What is the syntax for a comment in Markdown?

<!-- comment -->. It is HTML, and Markdown apps that allow HTML hide it.

How do I comment out a line in Markdown?

Wrap it in <!-- and -->. For a single line you can also write [//]: # (the line).

Do comments work in GitHub README files?

Yes. GitHub hides HTML comments in README files, issues and comments.

Next