How to properly add CSS in WordPress

December 3rd, 2010 |

It is important that the styles should not be added in hard-code way. Right way to include CSS is using the standard functions of WordPress wp_enqueue_style. It is a safe way that will save you from future troubles. Moreover, it is more convenient and makes your code more readable.

Using wp_enqueue_style

wp_enqueue_style($handle, $src, $deps, $ver, $media);


function my_init_method() {
                      get_template_directory_uri() . '/print.css',
                      false, false, 'print');
add_action('init', 'my_init_method');


// If IE7 add the Internet Explorer 7 specific stylesheet
global $wp_styles;
wp_enqueue_style('ie7-style', THEME_CSS  . '/ie7.css');
$wp_styles->add_data('ie7-style', 'conditional', 'lte IE 7');

Related articles:

  1. WordPress JS & CSS Script Optimizer
  2. Using WP3 Menu

There are no comments yet

Leave a Reply

Your email address will not be published. Required fields are marked *