Library / SDK
sindresorhus/github-markdown-css avatar
sindresorhus/github-markdown-css

github-markdown-css: GitHub's Markdown styling as a standalone stylesheet

The minimal amount of CSS to replicate the GitHub Markdown style

8,936 stars2,078 forksCSSMIT

At a glance

What is it?
A generated CSS package that reproduces how GitHub renders Markdown, shipped as seven theme files. It is a good fit for static docs and comment views, and a poor fit for anyone who wants a maintained design system.
Who is it for?
Adopt github-markdown-css if you render Markdown to HTML and want it to look like GitHub without writing typography rules yourself, especially if you already use GitHub's /markdown API or starry-night for code highlighting. Do not adopt it if you need a design system you can extend, or if you want the upstream project to accept your CSS changes: the README states the CSS is generated and contributions belong in sindresorhus/generate-github-markdown-css.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 11 days ago.
What is it written in?
Mainly CSS, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 27, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The problem: your Markdown renders, but it does not look like GitHub

Markdown parsers produce plain semantic HTML. Headings, tables, nested lists and fenced code blocks all come out as unstyled elements, so a README that looks tidy on github.com turns into browser defaults once you render it yourself. Writing that typography by hand means matching GitHub's font stack, its spacing between blocks, its table borders, its blockquote treatment and its code block backgrounds, and then doing it again for dark mode.

github-markdown-css exists to skip that work. It is a stylesheet, not a parser and not a component library. You render Markdown to HTML with whatever tool you already use, wrap the output in an element with the markdown-body class, and load the CSS. The README describes it as "the minimal amount of CSS to replicate the GitHub Markdown style", and the package ships seven files so the same markup can be shown in light, dark, dimmed, high-contrast and colorblind variants.

The audience is narrow but real: people building documentation sites, changelog pages, comment threads, static site generators, or email and PDF previews where the reader expects GitHub's visual conventions. If your goal is a custom brand identity, this is the wrong starting point.

How the package is structured: seven CSS files and one class name

The repository root holds the seven stylesheets listed in package.json's files array: github-markdown.css, github-markdown-light.css, github-markdown-dark.css, github-markdown-dark-dimmed.css, github-markdown-dark-high-contrast.css, github-markdown-dark-colorblind.css and github-markdown-light-colorblind.css. The default file is the one that switches automatically, using @media (prefers-color-scheme), while the others pin a single theme.

The contract is a single class. Everything in the stylesheet hangs off .markdown-body, so the CSS does not leak into your navigation, sidebar or footer unless you put those elements inside the container. That is the main reason this is easy to drop into an existing page: you are not adopting a global reset.

The files are generated, not hand-written. The README states plainly that contributions should go to sindresorhus/generate-github-markdown-css, and package.json shows how: each theme is produced by running the github-markdown-css CLI with a --theme value (light, dark, dark_dimmed, dark_high_contrast, dark_colorblind, light_colorblind, auto) and redirecting stdout into a file. The make script chains all seven. This matters for anyone planning to fork: editing the CSS in this repository is editing build output, and the next regeneration overwrites it.

Installing github-markdown-css and rendering a first page

The README gives three routes: download the file manually from the gh-pages branch, take it from CDNJS, or install with npm. The npm route pulls the seven CSS files into node_modules and exposes github-markdown.css as the package main.

bash
npm install github-markdown-css

After that, copy or link the stylesheet into your page and add the class. The README's own example sets a viewport meta tag, a box-sizing rule, a min-width of 200px, a max-width of 980px, centered margins, and 45px of padding, with 15px padding below 767px. Those numbers are the ones GitHub uses, so copying them keeps the proportions familiar.

html
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="github-markdown.css">
<style>
	.markdown-body {
		box-sizing: border-box;
		min-width: 200px;
		max-width: 980px;
		margin: 0 auto;
		padding: 45px;
	}

	@media (max-width: 767px) {
		.markdown-body {
			padding: 15px;
		}
	}
</style>
<article class="markdown-body">
	<h1>Unicorns</h1>
	<p>All the things</p>
</article>

What you should see is a heading and paragraph styled like a GitHub README, with the container capped at 980px. To force one theme instead of the automatic switch, point the link at github-markdown-light.css or github-markdown-dark.css. If you want the HTML itself to match what GitHub produces, the README points at GitHub's /markdown API, and for code block highlighting it suggests starry-night alongside your parser.

Quirks mode is the failure you will actually hit

The troubleshooting section names one specific symptom: tables in dark mode rendering their fonts in black. The cause it gives is not the stylesheet but the document, which the browser may be parsing in quirks mode. The fix is a doctype at the top of the page.

html
<!doctype html>
<html lang="en"><head></head><body></body></html>

This is worth taking seriously because the failure looks like a CSS bug and sends people hunting through the theme files. If your Markdown content is injected into a page fragment, an iframe, or a template that strips the doctype, you can lose standards mode without noticing until a dark theme is applied.

The second limitation is scope. The stylesheet styles rendered Markdown, not the editor that produces it. There is no JavaScript, no syntax highlighter and no parser in the package, so a toolbar, live preview or drag-and-drop image handling is entirely your problem. The README also notes that parsers other than GitHub's will "mostly" work, which is an honest hedge: parsers that emit different markup for footnotes, task lists or admonitions will not be covered by rules written for GitHub's output.

Alternatives: highlight.js themes and full CSS frameworks

The closest comparison is a syntax highlighting theme such as the ones shipped with highlight.js or Prism. Those style the code inside a block, with token colors for keywords, strings and comments. github-markdown-css styles the block itself, along with headings, lists, tables, blockquotes and the rest of the document. The two solve different halves of the same page, which is why the README suggests pairing this stylesheet with starry-night rather than treating highlighting as part of the package.

The other comparison is a general CSS framework. Frameworks give you a grid, buttons, form controls and a component vocabulary you can restyle. This package gives you one class and no components. If you need a design system, a framework is the better base and you would spend more time overriding github-markdown-css than using it. If you need a rendered README to look like a rendered README, the framework is more surface area than the job requires.

Maintenance, licence and the cost of regenerating CSS

The last push to the repository was on 2026-09-18, and the most recent release listed is v5.9.0 from 2026-02-03. The repository is not archived. Because the CSS is generated upstream, the practical upgrade path is to bump the npm version and replace the file you copied, rather than to patch rules in place. Any local edits you make to a theme file will be lost on the next update, so customizations belong in a separate stylesheet loaded after this one.

The package is MIT licensed, and package.json declares the same identifier. That is permissive and widely compatible, but the licence covers the CSS files in this repository; it does not grant you rights to GitHub's trademarks, logos or interface assets, and it says nothing about the terms of GitHub's /markdown API, which is a separate service you would be calling. The repository also carries a funding link in package.json. None of this is legal advice; read the licence file and the API terms yourself if the distinction matters to your product.

Editorial conclusion

Adopt github-markdown-css if you render Markdown to HTML and want it to look like GitHub without writing typography rules yourself, especially if you already use GitHub's /markdown API or starry-night for code highlighting. Do not adopt it if you need a design system you can extend, or if you want the upstream project to accept your CSS changes: the README states the CSS is generated and contributions belong in sindresorhus/generate-github-markdown-css. Before shipping, verify that your page starts with a doctype, since the troubleshooting section ties dark-mode table bugs to quirks mode, and check which of the seven theme files matches the GitHub theme you are imitating.

Frequently asked questions

How do I install github-markdown-css?

The README lists three options: download github-markdown.css manually from the gh-pages branch, take it from CDNJS, or run npm install github-markdown-css. The npm package exposes github-markdown.css as its main file and ships all seven theme stylesheets.

How do I enable dark mode with github-markdown-css?

The default github-markdown.css switches between light and dark automatically through the prefers-color-scheme media query. If you want to pin a theme instead, load github-markdown-dark.css, github-markdown-dark-dimmed.css or github-markdown-dark-high-contrast.css.

Can I contribute CSS changes to github-markdown-css?

The README states that the CSS is generated and that contributions should go to the sindresorhus/generate-github-markdown-css repository instead. The theme files here are build output produced by the github-markdown-css CLI with a --theme flag.

Does github-markdown-css work with Markdown parsers other than GitHub's?

The README says other Markdown parsers will mostly work with these styles, and points at GitHub's /markdown API for HTML that matches GitHub exactly. Parsers that emit different markup will not be covered by rules written for GitHub's output.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. sindresorhus/github-markdown-css on GitHub
For maintainers

Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/sindresorhus-github-markdown-css.svg)](https://hysenlabs.com/projects/sindresorhus-github-markdown-css)
Community notes

Community notes