WordPress Code Snippets

A fresh mix of code snippets and tutorials

WordPress enqueue user-agent stylesheets


WordPress makes it clean and easy to enqueue custom stylesheets via the functions.php file. Here’s how to do it for user-agent stylesheets.

To deliver custom stylesheets to specific user-agents, add the following code to functions.php:

This code basically grabs the WP-generated variables for IE, Opera, and other supported browsers, and then registers and enqueues a browser-specific stylesheet accordingly. So create a custom CSS file for each of your targeted browsers and/or remove the enqueue for any that aren’t required. Similar logic may be used to enqueue user-agent JavaScript and other resources. For more infos and options, visit the WordPress Codex:


If you need more control over specific browsers, here is a snippet of jQuery code to get you started:

Lots of folks will tell you NOT to do this, and I can’t say I disagree, but it’s a useful technique nonetheless. Note that there is probably a more efficient way of writing this snippet, or you could even use a script like modernizr for much more. Either way, the goal here is to provide options for you, the discerning individual, to find suitable solutions.

Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!