Skip to content

Learn

Timeline syntax

Learn periods, events, sections, wrapping, and direction used in the History of Social Media template.

On this page9 sections
  1. Syntax cheatsheet
  2. 1.Start a timeline
  3. 2.Time periods and events
  4. 3.Multiple events per period
  5. 4.Group periods into sections
  6. 5.Long labels and line breaks
  7. 6.Direction (LR and TD)
  8. 7.Put it together: History of Social Media
  9. Check your level

Syntax cheatsheet

Quick reference for this diagram type

ConceptSyntax
Declaretimeline · timeline TD · timeline LR
Titletitle My timeline
Sectionsection Age or era
Period + event2004 : Facebook
Extra events: Google (continuation under same period)
Inline multi-event2004 : Facebook : Google
Line breakLong text<br>on two lines
  1. 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 : Started
    Expand
  2. 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 : Shipped
    Expand
  3. 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 upload
    Expand
  4. 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 : Twitter
    Expand
  5. 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 software
    Expand
  6. 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 : GA
    Expand
  7. 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 : Twitter
    Expand

Check your level

80% or higher certifies this lesson. You'll get 35 random questions from a larger bank.