Admonitions in Markdown

Markdown logo

Admonitions are specially formatted blocks that highlight important information, show tips, display warnings, or notes in your Markdown files. The standard Markdown syntax doesn't include admonitions, however some extended Markdown flavors and documentation platforms provide ways to create these.

As each markdown processor differs in its syntax/approach, this lesson will provide some alternatives using the standard syntax along with HTML fallbacks.

Why use admonitions?

Admonitions are useful for various reasons:

  • Highlight important information - Raise warnings, requirements, or prerequisites.
  • Display tips or advice - Tips can be useful for documentation or tutorials.
  • Enhancd visuals - Breaks up long sections of text and improves readability.
  • Improve scannability - Help readers locate important notes at a glance.
  • Establish conventions - Create consistent patterns for presenting certain types of content.

Common admonition types

Most documentation systems support several types of admonitions including:

TypeDescription
WarningWarn readers about issues, errors, or potential problems.
InfoAdditional background information
NoteNotes for general information.
TipUseful advice or best practices.
CautionAdvice the user to be cautious.
ImportantKey information for the reader.
ExamplePractical demonstrations, examples, or sample code.
QuestionFrequently asked questions or quiz sections.
SuccessConfirmation messages or completion criteria.
DangerCritical/dangerous warning messages.

Admonition syntax/support can vary depending on your markdown processor or editor.

Using with blockquotes

To replicate a similar style which works in all markdown processors, a blockquote can be used (combined with a emoji if required 😄):

Syntax:

> :warning: **Warning:** NPM must be installed to proceed.

> :fire: **Tip:** Insert emojis into your markdown pages.

> :memo: **Note:** Admonition syntax is not supported in all markdown processors.

> :heart: **Success:** Lesson complete, you are making great progress!.

Result:

⚠️ Warning: NPM must be installed to proceed.

🔥 Tip: Insert emojis into your markdown pages.

📝 Note: Admonition syntax is not supported in all markdown processors.

❤️ Success: Lesson complete, you are making great progress!.

General HTML Approach

You can use HTML with CSS classes if admonition is not available in your Markdown editor:

Syntax:

<div class="note">
  <h4>Note</h4>
  <p>Admonition/note using HTML and CSS.</p>
</div>

CSS:

.note {
  margin: 10px;
  padding: 5px 10px;
  background-color:rgb(93, 92, 92);
  border-radius: 5px;
  border-left: 10px solid rgb(91, 135, 179);
}

Note

Admonition/note using HTML and CSS.

Bootstrap-style alerts with HTML

Syntax:

<div style="background-color: #fff3cd; color: #856404; padding: 15px; border-radius: 5px; border-left: 5px solid #ffeeba;">
  <strong>Warning!</strong> Backup your work before proceeding.
</div>

Result:

Warning! Backup your work before proceeding.

Details/Summary using HTML

Syntax:

<details>
  <summary><strong>Click to expand</strong></summary>
  <p>Hidden content will be revealed when expanded.</p>
</details>

Result:

Click to expand

Hidden content will be revealed when expanded.