Title: CSS link creating header errors&#8230;
Last modified: December 25, 2019

---

# CSS link creating header errors…

 *  [jwrbloom](https://wordpress.org/support/users/jwrbloom/)
 * (@jwrbloom)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/css-link-creating-header-errors/)
 * I’ve written a little plugin for myself, just putting my custom functions in 
   there for my site. Everything is going well except trying to link CSS files to
   it.
 * One of my functions was a standalone file before I decided to create a function
   for it instead of using INCLUDE. It works as its intended to work, except for
   the CSS.
 *     ```
       <link href="/styles/playerProfiles.css" rel="stylesheet" type="text/css">
       ```
   
 * I started it above the <?php, and I’ve tried to echo it within the function, 
   as well as a couple of other options. In all instances, the CSS works, but it’s
   creating the header errors below.
 * >  Warning: Cannot modify header information – headers already sent by (output
   > started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/
   > public_html/wp-includes/functions.php on line 6029
   > Warning: Cannot modify header information – headers already sent by (output
   > started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/
   > public_html/wp-admin/includes/misc.php on line 1252
   > Warning: Cannot modify header information – headers already sent by (output
   > started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/
   > public_html/wp-admin/admin-header.php on line 9
    -  This topic was modified 6 years, 3 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not a Developing with WordPress
      topic

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/css-link-creating-header-errors/#post-12267889)
 * Plugin files are processed very early. Anything outside of `<?php ?>` tags generates
   output. When WP then later tries to send its headers, your early output causes
   errors. If you want to directly output link tags, they need to be within the `
   <head>` section for the HTML to validate. To do so, you need to either edit the
   theme template containing the head section, or hook an action that fires at the
   right time. You could use the “wp_print_scripts” action for this, though your
   link may not exactly land in the optimal place. It’ll still work as long as there
   are no subsequent overrides in other CSS.
 * The proper way to reference external stylesheets is through `wp_enqueue_style()`.
   Then you can be assured the resulting link tag occurs in the optimal location.
 * You’ll also want to avoid relative file references, they work inconsistently 
   in WP. Always use the full absolute URL. You can get your plugin’s base URL with`
   plugin_dir_url()` which will work for any WP installation. You would never hardcode
   a full URL, always get it from a function.
 *  Thread Starter [jwrbloom](https://wordpress.org/support/users/jwrbloom/)
 * (@jwrbloom)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/css-link-creating-header-errors/#post-12268305)
 * I typically start PHP includes with ABSPATH.
 * For this, I went ahead and put the CSS link in the theme’s designated “custom
   HTML” section.

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

The topic ‘CSS link creating header errors…’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jwrbloom](https://wordpress.org/support/users/jwrbloom/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/css-link-creating-header-errors/#post-12268305)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
