Home > concrete5 for developers > typography.css in concrete5 themes

typography.css in concrete5 themes

September 10th, 2009 Leave a comment Go to comments

concrete5 recommends using additional typography.css stylesheet within a theme. I noticed that sometimes people don’t understand the purpose of the file and put there much trash, which shouldn’t be there. So what is typography.css and where it is used?

If you search the concrete5 source code, you’ll find only one case when typography.css is used: it is plugged by TinyMCE WYSIWYG editor in the default "Content" concrete5 block. In other words, this is the stylesheet being used in an editable content area when WYSIWYG is open. So if you place there something like

body {
  text-align: center;
}

It will completely mess your WYSIWYG area making all the text go centered. The final result might be ok (most probably you use some blocks with classes to align the content properly), but editing is a little confusive when you see centered text in edit mode and aligned to left in the final.

So, the first advice is to think twice before moving anything from general stylesheet to typography.css.

By the way, if you are just playing with typography.css, you might be confused by the stylesheet being cached. There is a workaround: open ‘concrete/blocks/content/editor_config.php’ and find the following line:

	content_css : "<?php echo $theme->getThemeEditorCSS(); ?>",

and change it in the next way:

	content_css : "<?php echo $theme->getThemeEditorCSS() . "?" . time(); ?>",

This will add timestamp to the stylesheet URI every time, so it won’t be cached. Don’t forget to remove this workaround once you are ready.

So, what should finally go to typography.css? Consider this:

If you have some global style defined through body and it is not changed in subsequent classes, use it. For example: font colors and font families are often defined globally for the whole content:

body {
    font-family: Arial;
    color: #393939;
}

If you have some style that is applied to ALL links, use it as well:

a {
    color: #393999;
    text-decoration: none;
}
a:hover {
    color: #3939c9;
    text-decoration: underline;
}

And if you have global styles for headings of any level, move it to typography.css as well:

h1 {
   font-size: 30px;
}
h2 {
   font-size: 22px;
}
h3 {
   font-size: 16px;
}

We hope this tutorial helps some developers build better concrete5 themes.

Categories: concrete5 for developers Tags:
  1. Chris Seymour @ c5mix.com
    September 11th, 2009 at 19:13 | #1

    Thanks for the timestamp tip with fixing the caching of typography.css. That was driving me nuts and couldnt figure out how to clear the cache. Great tips!

  2. December 27th, 2009 at 17:39 | #2

    If not all of your CSS-Settings of typography or your basic settings are used in the editor, you can modify
    concrete/js/tiny_mce/themes/concrete/skins/default/content.css
    and remove some of those css styles (i.e. body,pre,td,h1,h2,h3,h4,h5,h6).
    Then it takes those of your typography.css (which must reside in your theme root!)

  3. pthalacker
    February 17th, 2010 at 22:45 | #3

    I am missing something. Should I remove classes from main.css and put them in typography.css and then include typography.css in my theme template? Do I have to remove the basic elements from the default tinyMCE skin to have them appear in the editor, or will putting them in typography take precedence over the default editor skin?

  4. Andy Frahm
    November 2nd, 2011 at 21:53 | #4

    Anything you edit in the main concrete folder will need to be updated with every new release. There must be a better way.

  5. November 5th, 2011 at 17:20 | #5

    @Andy Frahm this fix with the timestamp is for web developers who need to debug and immediately see the changes in typography.css of the theme they are working on. It just prevents the browser from caching typography.css. There is absolutely no need to keep that workaround forever, so it’s not a problem if the core upgrade overwrites that edit.

    But if you for some reason need to keep that workaround forever, you can simply copy the files from /concrete/blocks/content/ to /blocks/content/ and make the changes there.

  1. No trackbacks yet.