Search code examples
htmlcsstagsthemestumblr

Defining style per tags in Tumblr


I would like to know how to define the specific style for specific tags. For instance, I would like to have my posts render a certain style if they're tagged with Croissant or Chocolate.

I think know I have to create a new class and I know I have to style this new class but I don't know how to do it.

Thanks for the help!


Solution

  • You'll need to use {TagsAsClasses} in your theme.

    For example, you'll need to write something like for your theme:

    <div id="{PostID}" class="post {PostType} {TagsAsClasses}">
      <!-- ... -->
    </div>
    

    If your post is a photo post and has the tags Croissant and Chocolate, then your HTML becomes:

    <div id="post-26107509778" class="post photo Croissant Chocolate">
      <!-- ... -->
    </div>
    

    and then you can set the styles for the .Croissant or .Chocolate classes:

    .Croissant {
      /* add your styles here */
    }
    
    .Chocolate {
      /* add your styles here */
    }
    

    More info here http://www.tumblr.com/docs/en/custom_themes