Do you want to add css for html generated by a plugin perhaps?
Got a Custom Theme?
Do you have a custom theme that you are NEVER going to automatically update?
Then edit the themes css, add your custom css to the bottom of the main style.css. This should be in your themes folder under wp-content.
Got an Updateable Theme ?
Does your theme have upates occasionally ? If you want to be able to auto update your theme, then it is better to add your css separately.
Some plugin have ways to add a custom css file for that plugin and/or to disable any plugin css so that you may reduce the number of stylesheets. Do NOT edit any plugin css files unless it is a site specific plugin that will not be updated automatically – you will lose your css when the update is applied.
The easiest way to add custom css if you cannot use your themes style.css is probably by using the official wordpress jetpack plugin: http://wordpress.org/support/plugin/jetpack
It has a custom css module http://jetpack.me/support/custom-css/ There are other plugins that allow you to do this.
How to work out what css selectors to use?
First you need to work out what css selectors have been provided in the html that is generated. My plugins generally offer many css selectors in the html. The various ‘inspect element’ tools are invaluable here.
Examples:
- http://getfirebug.com/css and
- https://developers.google.com/chrome-developer-tools/docs/elements.
- http://www.youtube.com/watch?v=oao2MmT78mI
They help highlight what css is being applied to the html and what is being overwritten. And of course they help you to see easily what css ‘hooks’ there are to add special styling.
Your custom css needs to work with your theme, so you either need to specify the css tightly enough that no theme css will ever override it, or know that you are not going to be changing themes.
To work out what css to add, ideally you should have a reasonable understanding of css. In particular the concepts of specificity and inheritance
http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/ .
You could ask for help from css experts.
- http://webmasters.stackexchange.com/questions/tagged/css or
- http://stackoverflow.com/questions/tagged/css or
- pay for a bit of wp related help https://www.google.com.au/search?q=www.wpquestions.com+css
When asking for help you should
- provide a link to the problem page of your site or demo site
- identify the theme you are using perhaps
- be clear and specific about the effect you are trying to achieve and your level of skill in editing css
Browser consistency
You should also know that browsers vary in their implementation and while your hack that you worked out or have been given might look beautiful on your apple mac running safari, results can vary greatly.
If you have any pride in your work at all, you should test the result using something like http://browsershots.org/, or risk the site looking really stupid.
Identifying CSS selectors example:
In this example from the amr-users plugin, one can see that:
- there are id’s specific to a user list, thus enabling one to isolate your css to just the list (div id=userlist1)
- there is a general userlist class which enables one to style all such userlists with the same css
- there are classes per field allowing one to style individual fields