Thesis Tips: Custom CSS Stylesheet

by

in Thesis Theme Tips

Thesis ThemeThe Thesis Custom CSS Stylesheet is the tool you use to build on the colours and fonts you set up in the Design Options screen, to make your WordPress site uniquely yours.

Keep in mind the point I made in the article on design options: in order to keep your site coding as efficient as possible (which speeds up site load times) you should keep your custom stylesheet as small as possible.

That means making sure that you only use it for tweaks that you can’t accomplish through the Design Options screen.

Why use a custom stylesheet instead of the theme’s primary stylesheet to make changes?

Because if you use the primary stylesheet you’ll lose all your customisations whenever you upgrade to the newest version of Thesis.

Using the Custom Stylesheet enables you to preserve your customisations.

Activate the Custom Stylesheet

The first thing you need to do is visit the Design Options screen and make sure that the custom stylesheet is activated:

Activate Custom Stylesheet

Check the ‘Use Custom Stylesheet’ check box and hit the Big Ass Save button.

Access the Custom Stylesheet

To access your custom stylesheet click the ‘Custom File Editor’ link in your Thesis sub-menu:

Custom File Editor Link

There are 3 files available for you to edit and the default is the custom.css file. Ignore the other two for now, as they’ll be covered in separate articles.

Custom files available for editing

The beauty of making style changes through the custom.css file is that if you get it all wrong you can just delete everything you’ve done and start again.

Your site styling will simply revert to the default layout, or the layout, colours and fonts that you’ve set up in the Design Options screen.

In other words you can’t screw up your site :) (At least, not by doing something in the custom stylesheet!)

Using the Custom CSS Stylesheet

Because of the way Thesis has been built everything you define in your custom stylesheet must be assigned to the .custom class.

The one exception to this is the BODY tag.

Apart from that one, all style declarations in the custom stylesheet must start with the .custom class.

So, for example, if you want to define some styling for the header div, your style declaration would start like this:

.custom #header { first-property: value; }

If you’re defining some styling for the sidebar class your declaration would be:

.custom .sidebar { first-property: value; }

A link would be:

.custom a, a:active { first-property: value; }

And so on.

In the article on the Design Options screen I described how to define the font size, family and colour for your headlines (H1 tag) by clicking/selecting the attributes you want on that screen.

But you cannot make those tags bold in the Design Options screen. You have to do that from the custom stylesheet.

I also said in that article that you should only use the custom stylesheet for items you cannot define in the Design Options screen.

Therefore, if you want to make your headlines bold, in addition to your preferred font family, font size and font colour, you would simply select those font settings in the Design Options screen and add the bold declaration to your custom stylesheet:

.custom H1 { font-weight: bold; }

Finding the correct selector to edit

One of the most frustrating things about working on the styling of a site that someone else has built is finding the correct selector to edit.

Some of the selectors (e.g. the header div) are obvious. Many are not.

There are two ways you can save yourself hours of frustration here:

  1. If you’re using Firefox, install the Firebug addon
  2. Go to the Thesis main stylesheet and locate the appropriate selector there

The Firebug addon is by far the best way of identifying the selector you need.

Once you’ve installed it you can simply activate it, select the ‘inspect’ tool (second item from the left on the toolbar), hold your cursor over the bit of the page you want to change and Firebug will give you the exact selector name.

If you’re using a browser that doesn’t support Firebug then you can go to the main Thesis stylesheet and read through it until you find the selector you’re looking for.

Often there will only be a minor difference from what you would expect (for example sidebar vs. sidebars).

Before discovering Firebug, I used to copy the code I needed from the main stylesheet, paste it into the custom stylesheet, delete all the stuff I didn’t need and edit the selector I did need.

As I said, Firebug is an infinitely better solution, but the second option will work if you can’t use Firebug for any reason.

OK, that’s it for the custom stylesheet. If you need any clarifications leave a comment and I’ll clarify :)

Cheers,

Martin Malden

Was this article useful? Please recommend it:
  
Get updates once a week, plus a free eBook on how to set up a business online - join us!

Your details are safe with me.
My Privacy Policy.

{ 6 comments }

Lissa Douglas January 22, 2011 at 9:58 pm

I love your site and the tips to tart up my menu bar. Strangely enough, the bold headline declaration, .custom H1 { font-weight: bold; }, makes all my headlines bold except on my homepage. My homepage seems, for some reason, to have “clickable” headlines. When I click on one, it does change to bold. Can you account for this, or, hopefully, tell me how to correct it.
Thanks!

Martin January 23, 2011 at 5:26 pm

Hi Lissa,

Many thanks for your very kind comments..!

I suspect that the H1′s on your home page have an additional selector to make them more specific. The additional selector is probably .entry-title

So the selector you want is probably .custom h1.entry-title

In any case, the best way of identifying the precise selector you want is to install Firebug and mouse over the headlines on your home page. Firebug will tell you in the panel at the bottom the correct name of the selector. Take it from there and be sure to be as specific as possible – i.e. include any additional selectors Firebug shows.

Cheers,

Martin.

Lissa Douglas January 24, 2011 at 1:59 am

Thanks, Martin, for your help! I just installed Firebug and it looks like a terrific tool but I don’t get how to use it. I moused over the headline on my homepage but the Firebug panel did not seem to respond to my cursor position. I played with the buttons on the Firebug toolbar- including the CSS button, which took me to CSS, but I couldn’t find the H1 selector. For some reason, the additional suggestion you made above also didn’t work as a selector. Can you help me get Firebug to respond to the position of my cursor? In my stumblings, activated something and restarted Firefox, and then I got an error which says “Permission denied for to get property Location.toString from ” and nothing else will display on that particular panel. I don’t know if that’s relevant or not.

Peace,

Lissa

Lissa Douglas January 24, 2011 at 2:21 am

Sorry. I re-read your article– and followed your VERY PRECISE instructions– used the selector tool, and– VOILA! exactly what I wanted. I found out I was using H2 for my headline, not Hi, and this is why it didn’t register the “bold” change. So now my question is, how can I tell my computer to change only the H2 headlines on my HOMEPAGE to be bold?

Boldly,

Lissa

Lissa Douglas January 24, 2011 at 2:43 am

Wait! There’s more… I’m now not sure which is the selector I should use. This is the code that Firebug pointed out that was in the grey area at the top:
a<h2 entry-title <div.headline_area <div#post…post-201 <div#content.hfeed <div#content_box <div.page <div#content…II_width <body.custom <html

Any insights would be helpful.

Thanks,

Lissa

Martin January 24, 2011 at 6:55 am

Hi Lissa,

All you need to do is mouse over the thing you want to change with the inspector tool. Keep in mind that if you change H2 it will change H2 throughout your site.

A key element of CSS is what they call ‘specificity’ – which means you can add qualifying selectors to a selector (e.g. h2.entry-title) where the ‘entry-title’ further qualifies the H2. This will enable you to isolate specific areas where h2 is used.

So if something hasn’t done what you expected it to it may have been further qualified – so in each case use the inspector tool to see if there’s a qualifying selector and then add that more specific selector to your custom CSS file.

This may mean you have to use 2 selectors in a CSS line, which you can do by separating them with commas – e.g. h2, h2.entry-title (assuming you want them all to behave in the same way).

Cheers,

Martin.

Comments on this entry are closed.

{ 2 trackbacks }

Previous post:

Next post: