Title: echo IE conditional css in header
Last modified: August 30, 2016

---

# echo IE conditional css in header

 *  [Zane](https://wordpress.org/support/users/xane_777/)
 * (@xane_777)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/echo-ie-conditional-css-in-header/)
 * Hi there,
 * I hope this is the right place to post this question. It is more about PHP syntax.
   Although I need it for my theme 🙂
 * I want to add IE specific stylesheets in the header of my theme. So not wanting
   to touch the original (Thematic) header.php I want to add a function that will
   do the job.
 * My code looks like this
 *     ```
       function ie_styles() {
       echo "<!--[if IE]><link rel="stylesheet" type="text/css" href="all-ie-only.css" /><![endif]-->";
       }
   
       add_action( 'thematic_header','ie_styles',1 );
       ```
   
 * and it breaks my theme. The function works if I only echo “Test” (for example).
 * My only guess is that I am not correctly striking out characters within my echo
   statement?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Sampression](https://wordpress.org/support/users/sampression/)
 * (@sampression)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/echo-ie-conditional-css-in-header/#post-6711943)
 * Hello Zane,
 * Add the following function to the functions.php file of your child theme
 *     ```
       function ie_styles() {
           global $wp_styles;
           echo '<!--[if IE]>';
           wp_enqueue_style('ie_only', get_stylesheet_directory_uri() . 'all-ie-only.css');
           echo '<![endif]-->';
           $wp_styles->add_data( 'ie_only', 'conditional', 'IE' );
       }
       add_action( 'wp_enqueue_scripts','ie_styles');
       ```
   
 * Hope this helps.
 * Thanks
 *  Thread Starter [Zane](https://wordpress.org/support/users/xane_777/)
 * (@xane_777)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/echo-ie-conditional-css-in-header/#post-6711978)
 * Hi Sampression,
 * mmm…seems like my approach was only a ‘little’ off 🙂
 * Thank you very much! I will give this a try.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘echo IE conditional css in header’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * 2 replies
 * 2 participants
 * Last reply from: [Zane](https://wordpress.org/support/users/xane_777/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/echo-ie-conditional-css-in-header/#post-6711978)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
