<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc" -->

---
title: Nested Code Fences in Markdown | daily.dev
description: CommonMark and GitHub Flavored Markdown support nested code fences and backticks through specific syntax patterns. For code blocks, use tildes (~) or more than...
canonical: https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Nested Code Fences in Markdown | daily.dev
og:description: CommonMark and GitHub Flavored Markdown support nested code fences and backticks through specific syntax patterns. For code blocks, use tildes (~) or more than...
og:url: https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc
og:image: https://api.daily.dev/og/posts/wzkhr78wc.png
og:image:alt: Nested Code Fences in Markdown
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nested Code Fences in Markdown

**[Hacker News](https://daily.dev/sources/hn)** · 6 min read · 0 upvotes · 0 comments

## Summary

CommonMark and GitHub Flavored Markdown support nested code fences and backticks through specific syntax patterns. For code blocks, use tildes (~) or more than three backticks to wrap content containing triple backticks. For inline code spans containing backticks, use multiple backticks as delimiters with spaces—the renderer automatically strips one space from each end. These techniques prevent rendering issues when displaying code examples that themselves contain Markdown fence characters.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://susam.net/nested-code-fences.html>

## Similar posts on daily.dev

- [Wrapper Elements around Code Blocks in Markdown—zachleat.com](https://daily.dev/posts/wrapper-elements-around-code-blocks-in-markdown-zachleat-com-ihigyfzsr) · Zach Leatherman · 0 upvotes · 0 comments
- [GitHub for Beginners: Getting started with Markdown](https://daily.dev/posts/github-for-beginners-getting-started-with-markdown-ugo2cwvfu) · GitHub Blog · 1 upvotes · 1 comments
- [Ruby Multiline Comments Explained with Examples](https://daily.dev/posts/ruby-multiline-comments-explained-with-examples-szdbqw4wl) · RUBYLAND · 0 upvotes · 0 comments

---

Tags: [#html](https://daily.dev/tags/html), [#markdown](https://daily.dev/tags/markdown)

[View this post on daily.dev](https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Nested Code Fences in Markdown","url":"https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc"},"datePublished":"2026-01-21T16:23:18.495Z","dateModified":"2026-01-21T16:23:41.316Z","description":"CommonMark and GitHub Flavored Markdown support nested code fences and backticks through specific syntax patterns. For code blocks, use tildes (~) or more than...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2cba3f49d515b826577ae03f52d4a543?_a=AQAEulh","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2cba3f49d515b826577ae03f52d4a543?_a=AQAEulh","isAccessibleForFree":true,"articleSection":"Hacker News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hacker News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/hn","url":"https://daily.dev/sources/hn"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/nested-code-fences-in-markdown-wzkhr78wc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"html,markdown","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hacker News","item":"https://daily.dev/sources/hn"},{"@type":"ListItem","position":3,"name":"Nested Code Fences in Markdown"}]}
```

