Post Pic

Save time using WordPress default CSS stylesheet

Many themes developer are loosing aprecious time while creating WordPress themes, because they redefine many CSS style which are already styled by default. In fact, WordPress provide a CSS stylesheet that you can use and save a big time!

If you always wanted to be able to get default styling from WordPress basic elements as such as post images, smileys, the .alignleft, .alignright or .aligncenter css classes you just have to use the wp.css stylesheet.

Just click here to get a preview of what elements, ids and classes this css defines.

To include it on your theme, simply upload the file to your wp-content/themes/yourtheme directory and paste the following line on your header.php file, within the <head> and </head> tags:

<link rel='stylesheet' href='/wp.css' type='text/css' media='all' />

Thanks to Ian Stewart for the tip!

21 Responses

Aug 20 2009 14:34

Never knew about that CSS file, looks like it’s hosted on Ian’s Google Code account.

I usually use the CSS code on this page, however Ian’s has a few more selectors.

Aug 20 2009 17:17

Note that the code given will link to the wp.css file at http://example.com/wp.css, which isn’t the location described just prior to the code in the post.

The actual code should be

<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/wp.css" type="text/css" media="all" />

Aug 20 2009 18:55

I can’t believe I never thought about this! This is very useful, especially when you try to align elements on left/right.

Aug 20 2009 22:18

That’s not a stylesheet WordPress provides by default, it’s a stylesheet Ian Stewart provides by default. :)

Aug 24 2009 09:55

Wow! Now I won’t have to redeclare .alignleft, .more-link, and the others now and then…

5 stars for this one! :)

Aug 24 2009 18:57

This is a great tip and will save me some time. This is so simple that I never thought of it before. :-)

Aug 29 2009 02:37

I don’t understand why you want to put one more css file in your theme
I don’t think it can save time.

Aug 29 2009 14:21

@V>C> : Seriously. I’m tired of those “I don’t understand” people. Why everyone else understands?

Aug 31 2009 17:56

jajaja xD Take it easy, Jean. You´re so smart, dude. I ever enjoy yuor blog xD

Sep 01 2009 18:57

Wowww… simple, but very useful tips. Thank you very much

Sep 02 2009 03:48

What does this mean? Wordpress (self-hosted) comes with a style sheet included when downloaded, so if that is not the default, then what is this? What is the difference?

Sep 04 2009 17:51

This tip save me a lot time. thx!

Sep 08 2009 07:05

Thanks, very useful tips

Sep 15 2009 21:26

Simple hack, that would save a huge amount of time…Thanks a bunch, guys!

Feb 05 2010 13:13

I agree with V.C, there’s no need (and it’s not a good practice) to include another stylesheet file, you’re adding one more call to your pages and it affects the loading speed. It’s much better to copy the contents of the file to your theme’s style.css.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required