Learn
Timeline syntax
Learn periods, events, sections, wrapping, and direction used in the History of Social Media template.
On this page9 sections
Syntax cheatsheet
Quick reference for this diagram type
| Concept | Syntax |
|---|---|
| Declare | timeline · timeline TD · timeline LR |
| Title | title My timeline |
| Section | section Age or era |
| Period + event | 2004 : Facebook |
| Extra events | : Google (continuation under same period) |
| Inline multi-event | 2004 : Facebook : Google |
| Line break | Long text<br>on two lines |
- 1
Start a timeline
Begin with the timeline keyword so Mermaid knows you want a chronology diagram.
Add an optional title on the next line with title followed by the heading text.
- Tip: Timeline is experimental in Mermaid — syntax for periods and events is stable; icon integration may still change.
timeline title My timeline 2024 : StartedExpand - 2
Time periods and events
Each data line starts with a time period, then a colon, then the event text.
Periods and events are plain text — not limited to years or numbers.
timeline title Product milestones 2024 : Started 2025 : ShippedExpand - 3
Multiple events per period
Put several events on one line with extra colons, or continue with lines that start with a colon under the same period.
Order matters: earlier events sit above later ones for that period.
- Tip: Continuation lines (: event) attach to the most recent period above them.
timeline title Early years 2004 : Facebook : Google 2005 : YouTube : First video uploadExpand - 4
Group periods into sections
Use section followed by a name to group following periods into an age or era.
A new section starts when you declare another section. Periods without a section use the default group.
- Tip: Periods in the same section share a color scheme so related eras are easy to scan.
timeline title History of Social Media section Early years 2002 : LinkedIn 2004 : Facebook : Google section Growth 2005 : YouTube 2006 : TwitterExpand - 5
Long labels and line breaks
Long period or event text wraps by default so it stays inside the diagram.
Force a break with <br> when you want a specific two-line label.
timeline title Industrial eras Industrial Revolution<br>phase one : Steam and mechanization Digital age : Networks<br>and softwareExpand - 6
Direction (LR and TD)
After timeline you can set direction: LR (left to right, default) or TD (top to bottom).
Use TD when a vertical chronology reads better for your layout.
- Tip: Direction support requires Mermaid v11.14.0 or newer.
timeline TD title Vertical milestones 2024 : Alpha 2025 : Beta 2026 : GAExpand - 7
Put it together: History of Social Media
Combine title, sections, periods, and multi-event lines into the examples template.
timeline title History of Social Media section Early years 2002 : LinkedIn 2004 : Facebook : Google section Growth 2005 : YouTube 2006 : TwitterExpand
Check your level
80% or higher certifies this lesson. You'll get 3–5 random questions from a larger bank.