Explaining the Tachyons CMS/Nested module

By Jason Li

2016 December 19

How it works

Tachyons CSS works by attaching single-purpose classes to HTML tags, but we don’t always have control over every HTML tag or component on a website. For example, in Wordpress, there’s a freeform blog-post box where users can do anything from penning a simple blog post to writing a complex article with custom HTML.

In cases like this, the best that we can do is to target HTML tags from the surrounding <div> using nested (or child) CSS selectors. So the class .nested-copy-line-height p { line-height: 1.5; } targets all the paragraphs in the blog post and applies a default line-height property to them.

Why not just use search and replace?

It is, of course, possible to write search and replace functions to apply the classes locally on a tag-by-tag basis. Even thought that’s much more in line with how Tachyons works, I generally caution against doing this for several reasons:

Having said that, if you do build an open source search-and-replace function for popular CMS platforms, please drop me a line.

Case study: Vanilla Milkshake Wordpress theme

Check out the Vanilla Milkshake Wordpress theme on Github.

To target the various tags that Wordpress outputs from its system, my surrounding <div> looks like this:

<div class="f5 f4-l measure nested-copy-line-height nested-headline-sansserif nested-headline-line-height nested-img nested-figure nested-embeds nested-hr nested-code nested-list nested-blockquote nested-dt nested-table nested-link nested-form"> 

Which corresponds to the classes below. Note that the core Nested module only includes a few classes and is more of a “starter pack” than a comprehensive solution:

.nested-copy-line-height p,
.nested-copy-line-height ul,
.nested-copy-line-height ol {
  line-height: 1.5;

.nested-headline-sansserif h1,
.nested-headline-sansserif h2,
.nested-headline-sansserif h3,
.nested-headline-sansserif h4,
.nested-headline-sansserif h5,
.nested-headline-sansserif h6
  font-family: -apple-system, BlinkMacSystemFont, 'avenir next', avenir, 'helvetica neue', helvetica, ubuntu, roboto, noto, 'segoe ui', arial, sans-serif;

.nested-headline-line-height h1,
.nested-headline-line-height h2,
.nested-headline-line-height h3,
.nested-headline-line-height h4,
.nested-headline-line-height h5,
.nested-headline-line-height h6 {
  line-height: 1.25;

.nested-img img {
  max-width: 100%;
  display: block;
  height: auto;
  width: inherit;

.nested-figure figure {
  max-width: 100%;
  height: auto;

.nested-embeds iframe,
.nested-embeds embed,
.nested-embeds object,
.nested-embeds video {
  max-width: 100%;

.nested-hr hr {
  border: 1px solid #FFFFFF;
  margin: 2rem 0;

.nested-code pre,
.nested-code code {
  font-size: .875em;
  padding: 0.5em;
  margin: 0.5em 0;
  background-color: #EEE;
  display: block;
  color: #444444;

.nested-list ul {
    list-style: none;
    padding-left: 1em;

.nested-list li {
  margin-top: 0.5rem;
  margin-bottom: 1rem;

.nested-list ul > li:before {
    content: "\25AA";
    display: block;
    color: #999;
    height: 0;
    width: 0;
    left: -1em;
    top: 0;
    position: relative;

.nested-blockquote blockquote {
  margin-left: 0;
  padding-left: 0.75em;
  border-left: 0.25em solid #FFFFFF;

.nested-dt dt {
  margin: 0.5rem 0;

.nested-table table {
  border-collapse: collapse;

.nested-table thead {
  border-bottom: 2px solid #333;

.nested-table th,
.nested-table td {
  padding: 0.67rem 0.5rem;
  text-align: left;

.nested-link a, .link {
  text-decoration: none;
.nested-link a, .link,
.nested-link a:link, .link:link,
.nested-link a:visited, .link:visited,
.nested-link a:hover, .link:hover,
.nested-link a:active, .link:active {
  color: #000;
.nested-link a:link, .link:link {
  border-bottom: 1px solid #aaa;
.nested-link a:visited, .link:visited {
  border-bottom: 1px solid #ddd;
.nested-link a:active, .link:active {
  border-bottom: 1px solid #333;

That’s a lot of nested classes. Doesn’t the sheer quantity defeat the point of using Tachyons? A little bit, but the alternative is no better – would you like to write a search and replace for this many exceptions?

P.S. This blog post is also styled using Tachyons CMS/Nested, albeit under Ghost not Wordpress. Feel free to inspect element, view source, etc. :)

Relevant links:

By Jason Li.

See other articles in Tachyons CSS or go home.