CSS » Themes

m.css pro­vides two themes, a dark and a light one. A theme con­sists of just a set of CSS vari­ables, which af­fect fonts, col­ors and oth­er prop­er­ties. The theme file is al­so an self-con­tained en­try point for the whole m.css frame­work — it in­cludes all the oth­er nec­es­sary CSS files ex­cept fonts via CSS @import state­ments.


The dark theme is de­scribed in the m-dark.css (or m-dark.compiled.css) file. Be­sides that, you need to ref­er­ence al­so Source Sans Pro font (used for page copy) and Source Code Pro (used for pre-for­mat­ted text and code). You can get them on Google Fonts. Full markup in­clud­ing theme col­or (used for ex­am­ple by Vi­val­di or An­droid brows­er) is be­low:

<link rel="stylesheet" href="m-dark.css" /> <!-- or m-dark.compiled.css -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?Source+Sans+Pro:400,400i,600,600i%7Cfamily=Source+Code+Pro:400,400i,600" />
<meta name="theme-color" content="#22272e" />

This theme is used on this site and al­so on http://mag­num.graph­ics.


The light theme is de­scribed in the m-light.css file. Be­sides that, you need to ref­er­ence al­so Li­bre Baskerville font (used for page copy) and Source Code Pro (used for pre-for­mat­ted text and code). You can get them on Google Fonts.

<link rel="stylesheet" href="m-light.css" /> <!-- or m-light.compiled.css -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,400i,700,700i%7CSource+Code+Pro:400,400i,600" />
<meta name="theme-color" content="#cb4b16" />

If you want to see this theme live, go to http://blog.mosra.cz.

Make your own

Mak­ing your own theme is usu­al­ly just a mat­ter of mod­i­fy­ing CSS vari­ables in the top-lev­el file. To give an ex­am­ple, a por­tion of the m-dark.css file looks like this:

:root {
  /* Text properties */
  --font: 'Source Sans Pro', sans-serif;
  --code-font: 'Source Code Pro', monospace;
  --font-size: 16px;
  --paragraph-indent: 1.5rem;
  --paragraph-align: justify;
  --link-decoration: underline;
  --link-decoration-nav: none;
  --link-decoration-heading: none;
  --nav-brand-case: uppercase;
  --nav-menu-case: none;
  --nav-heading-case: uppercase;
  --nav-categories-case: lowercase;
  --landing-header-case: lowercase;
  --heading-font-weight: bold;

  /* Shapes */
  --border-radius: 0.2rem;

  /* Basics */
  --background-color: #2f363f;
  --color: #dcdcdc;
  --line-color: #405363;

The project al­so bun­dles a Python script for postpro­cess­ing the CSS files in­to a sin­gle *.compiled.css file with­out @import state­ments or vari­ables, if you need. Down­load it here:

Its us­age is sim­ple — just call it with the files you want to com­pile to­geth­er and it will cre­ate a *.compiled.css file in the same di­rec­to­ry:

cd css
./postprocess.py m-dark.css # Creates a m-dark.compiled.css file

If you want to mod­i­fy the Pyg­ments style, it’s a bit more in­volved. You need to ed­it the *.py file in­stead of the *.css:

Af­ter mak­ing changes, copy it some­where so Pyg­ments can load it as a style and then gen­er­ate a CSS file out of it:

sudo cp pygments-dark.py /usr/lib/python3.6/site-packages/pygments/styles/dark.py
pygmentize -f html -S dark -a .m-code > pygments-dark.css

sudo cp pygments-console.py /usr/lib/python3.6/site-packages/pygments/styles/console.py
pygmentize -f html -S console -a .m-console > pygments-console.css