Markdown & Web Content Guide
Markdown is the lingua franca of web content. From GitHub READMEs and documentation sites to blog platforms and note-taking apps, Markdown powers how millions of people write and publish on the web. This guide covers the core syntax, extended flavors, HTML conversion, security considerations, and related content utilities.
1. What is Markdown?
Markdown is a lightweight markup language created by John Gruber in 2004, with significant collaboration from Aaron Swartz on the original syntax description. It was designed with a dual-purpose philosophy: Markdown files should be readable as plain text without any special rendering, while also being easily convertible to structurally rich HTML for publishing on the web. This simplicity is what makes Markdown so enduring -- you can write it in any text editor, store it in version control, and render it into beautiful web pages.
Markdown has become the standard format for technical documentation and web content across many platforms. GitHub uses it for READMEs, issues, and discussions. Static site generators like Hugo, Jekyll, and Astro rely on Markdown as their primary content format. Blog platforms such as Ghost and Hashnode support Markdown editing. Note-taking apps including Obsidian, Notion, and Bear use Markdown or Markdown-compatible syntax. Even documentation platforms like Notion, Confluence, and Docusaurus support Markdown input.
Compared to rich text editors (WYSIWYG editors like Microsoft Word or Google Docs), Markdown offers distinct advantages and trade-offs. Markdown is highly portable -- plain text files work everywhere and never suffer from format corruption. It is version-control friendly because diffs are meaningful (you can see what changed in a sentence without parsing XML). It is fast to write once you learn the syntax, with no menus or toolbar clicks needed. However, Markdown has limited formatting options compared to WYSIWYG -- you cannot easily control font sizes, colors, or complex layouts. Tables and mathematical notation have a steeper learning curve. And for non-technical users, the syntax can feel unfamiliar compared to the visual approach of rich text editors.
2. Markdown Basics
The core Markdown syntax covers the most common formatting needs with minimal keystrokes. Here is a practical overview of each element.
Headings
Headings are created with hash characters. Use one to six hashes for heading levels 1 through 6:
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6Level 1 headings are typically used only once per document (as the page title), while levels 2 and 3 are the most commonly used for section and subsection organization.
Paragraphs
Paragraphs are separated by one or more blank lines. A single line break within a paragraph does not create a new paragraph -- you need a blank line between blocks of text.
Text Formatting
Bold text is created with double asterisks or double underscores: **bold** or __bold__. Italic text uses single asterisks or underscores: *italic* or _italic_. Strikethrough uses double tildes: ~~strikethrough~~. You can combine them: ***bold italic*** produces bold italic.
Links and Images
Links use the syntax [link text](URL). You can add a title attribute: [link text](URL "title"). Images are identical in syntax but prefixed with an exclamation mark: . The alt text is important for accessibility and is displayed when the image fails to load.
Lists
Unordered lists use hyphens, asterisks, or plus signs (they are interchangeable). Ordered lists use numbers followed by periods. Nested lists are created by indenting four spaces:
- First item
- Second item
- Nested item (4-space indent)
- Another nested item
- Third item
1. Step one
2. Step two
3. Step threeBlockquotes
Blockquotes are created with the > character. Nested blockquotes use multiple > characters. They are commonly used for callouts, quotations, and highlighted text in documentation.
> This is a blockquote.
>> This is a nested blockquote.Code
Inline code uses single backticks: `code here`. Fenced code blocks use triple backticks with an optional language identifier for syntax highlighting:
```javascript
function greet(name) {
return `Hello, ${name}!`;
}
```Horizontal Rules
Horizontal rules are created with three or more hyphens, asterisks, or underscores on a line by themselves: ---, ***, or ___.
3. Extended Markdown / GFM
GitHub Flavored Markdown (GFM) extends the original Markdown specification with several features that have become de facto standards across platforms. GFM is now supported by most Markdown parsers and platforms.
Tables
Tables use pipe characters to define columns. Colons in the separator row control alignment: :--- for left, :---: for center, and ---: for right alignment:
| Left | Center | Right |
|:-----|:------:|------:|
| A | B | C |
| D | E | F |Task Lists
Task lists use square brackets. An x inside the brackets marks the task as complete:
- [x] Set up project repository
- [x] Write documentation
- [ ] Deploy to productionAutolinks
In GFM, bare URLs are automatically converted to clickable links. You do not need to wrap them in angle brackets or markdown link syntax.
Strikethrough
While originally not part of standard Markdown, strikethrough with ~~text~~ is now supported in virtually all Markdown parsers through GFM influence.
Emoji Shortcodes
Many platforms support emoji shortcodes like :smile:,:rocket:, and :check_mark:. These are converted to Unicode emoji characters during rendering.
Footnotes
Footnotes provide a way to add reference notes without cluttering the main text. Use [^1] in the body and define it elsewhere with [^1]: Definition text..
4. Markdown to HTML Conversion
Markdown parsers convert plain text into HTML through a three-stage pipeline: tokenize (scan the input and identify Markdown elements), parse (build a syntax tree from the tokens), and render (output HTML from the tree). Different parsers handle edge cases differently, which is why the same Markdown can produce slightly different HTML across platforms.
The most popular JavaScript Markdown parsers include:
- marked.js -- A fast, lightweight parser focused on speed and standards compliance. It is widely used in web applications and has a small bundle size.
- markdown-it -- A highly extensible parser with a plugin architecture. It powers many documentation platforms and supports CommonMark compliance.
- remark / unified -- An ecosystem built on an abstract syntax tree (AST) approach. Remark parses Markdown into an AST, which can be transformed with plugins and serialized back to Markdown or HTML. This approach is powerful for linting and programmatic manipulation.
One important feature of Markdown is that you can embed raw HTML directly in your Markdown files. The parser will pass through HTML blocks unchanged. This is useful for adding elements that Markdown does not support natively, such as iframes, custom divs with classes, or embedded widgets.
5. HTML Sanitization & Security
Because Markdown allows inline HTML, it introduces a significant security risk: Cross-Site Scripting (XSS). A user who can submit Markdown content can embed <script> tags, event handlers like onerror, or other malicious HTML that will execute in other users' browsers. This is a critical concern for any application that accepts user-generated Markdown.
Sanitization is the process of cleaning HTML output to remove dangerous elements while preserving safe content. The recommended approach is an allowed tags whitelist: define a list of safe HTML tags (like p, strong, em, a, code, ul, ol, li, h1-h6,table, blockquote) and strip everything else. Attributes should also be filtered -- for example, only allow href on anchor tags and reject onclick.
The two most widely used sanitization libraries are DOMPurify(a browser-focused library that uses the browser's own HTML parser for robustness) and sanitize-html (a Node.js library with extensive configuration options). Both support custom whitelists and handle edge cases like SVG-based XSS attacks.
Content Security Policy (CSP) headers provide a defense-in-depth layer by instructing the browser to block inline scripts. Even if sanitization fails, CSP can prevent the script from executing. Best practice: always sanitize user-provided Markdown before rendering, and use CSP headers as an additional layer of protection.
6. Content Preview & Rendering
Modern Markdown editors typically provide a live preview where the editor and rendered output are shown side by side. As you type Markdown on the left, the HTML preview updates in real time on the right. This split-pane approach gives you the best of both worlds -- the speed of plain text editing with the visual feedback of a WYSIWYG editor.
There are two main editing paradigms. WYSIWYG editing hides the Markdown syntax and shows only the rendered output, with formatting applied through toolbar buttons and keyboard shortcuts. Examples include Notion, Google Docs-style editors, and some blog platforms. Markdown-first editingshows the raw Markdown with a separate preview pane. Examples include VS Code with Markdown preview, Obsidian, and Stack Overflow's editor.
Syntax highlighting in code blocks is handled by libraries like highlight.js and Prism. They detect the programming language specified in the fenced code block and apply color-coded token highlighting. This makes code examples significantly more readable.
Math rendering supports LaTeX mathematical notation within Markdown. Libraries like KaTeX (fast, lightweight) and MathJax (comprehensive, supports more LaTeX features) render equations written between $ delimiters (inline) or $$ delimiters (display). This is essential for academic and technical documentation.
Diagram rendering with Mermaid allows you to create flowcharts, sequence diagrams, Gantt charts, and more using text-based syntax inside fenced code blocks. Many documentation platforms now support Mermaid natively, making it possible to include complex diagrams without external image files.
7. Text-to-Handwriting on the Web
Text-to-handwriting is a creative web utility that converts digital text into handwritten-style output. It addresses a common problem: digital text feels impersonal and generic. Whether you are writing a personal letter, creating educational materials, or designing a creative project, handwritten text adds warmth and authenticity that standard fonts cannot replicate.
Common use cases for text-to-handwriting conversion include personalized letters (thank-you notes, greeting cards, invitations), educational worksheets (practice sheets that look like they were written by hand for a more natural feel), creative projects (scrapbooking, journaling, art projects), and avoiding the "digital look" (making printed materials feel more personal and human).
Under the hood, text-to-handwriting utilities work through several techniques. Font mapping uses handwriting-style fonts to render text in a handwritten appearance. Variable letter forms introduce slight variations in each character so that repeated letters do not look identical (a dead giveaway of fake handwriting). Baseline variation slightly shifts characters up and down from the text baseline to simulate the natural irregularity of human writing.
Implementation approaches range from simple to sophisticated. The simplest method uses custom web fonts with handwriting styles. More advanced utilities use HTML5 Canvas rendering to draw each character with random slight variations in position, rotation, and size. The most realistic results come from SVG path-based rendering, where each character is a hand-drawn SVG path with variable control points. These techniques can be combined for increasingly natural-looking output.
8. Markdown & Content Utilities & Resources
KnowKit provides several utilities related to Markdown and web content creation. All utilities run entirely in your browser -- no data is sent to any server.
- Markdown to HTML Converter -- Convert Markdown text to clean HTML output. Paste your Markdown and get formatted HTML instantly.
- Markdown Preview -- View a live rendered preview of your Markdown with split-pane editing and real-time updates.
- Text to Handwriting -- Convert digital text to realistic handwritten-style output with customizable fonts and paper styles.
Whether you are writing documentation, publishing blog posts, creating educational content, or simply prefer the simplicity of plain text editing, Markdown is an invaluable skill for web content creation. Combined with proper sanitization for security and the right preview and rendering utilities, it provides a fast, portable, and version-control friendly workflow that scales from personal notes to large documentation sites.
Nelson
Developer and creator of KnowKit. Building browser-based tools since 2024.