Title: wp_register_style
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_register_style( string $handle, string|false $src, string[] $deps = array(), string|bool|null $ver = false, string $media = 'all' ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#wp--skip-link--target)

Registers a CSS stylesheet.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#see-also)󠁿

 * [WP_Dependencies::add()](https://developer.wordpress.org/reference/classes/WP_Dependencies/add/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#parameters)󠁿

 `$handle`stringrequired

Name of the stylesheet. Should be unique.

`$src`string|falserequired

Full URL of the stylesheet, or path of the stylesheet relative to the WordPress 
root directory.
 If source is set to false, stylesheet is an alias of other stylesheets
it depends on.

`$deps`string[]optional

An array of registered stylesheet handles this stylesheet depends on.

Default:`array()`

`$ver`string|bool|nulloptional

String specifying stylesheet version number, if it has one, which is added to the
URL as a query string for cache busting purposes. If version is set to false, a 
version number is automatically added equal to current installed WordPress version.

If set to null, no version is added.

Default:`false`

`$media`stringoptional

The media for which this stylesheet has been defined.
 Default `'all'`. Accepts 
media types like `'all'`, `'print'` and `'screen'`, or media queries like ‘(orientation:
portrait)’ and ‘(max-width: 640px)’.

Default:`'all'`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#return)󠁿

 bool Whether the style has been registered. True on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#source)󠁿

    ```php
    function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
    	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

    	return wp_styles()->add( $handle, $src, $deps, $ver, $media );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions-wp-styles.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/functions.wp-styles.php#L129)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/functions.wp-styles.php#L129-L133)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_styles()](https://developer.wordpress.org/reference/functions/wp_styles/)`wp-includes/functions.wp-styles.php` |

Initializes $wp_styles if it has not been set.

  |

| Used by | Description | 
| [wp_options_connectors_wp_admin_enqueue_scripts()](https://developer.wordpress.org/reference/functions/wp_options_connectors_wp_admin_enqueue_scripts/)`wp-includes/build/pages/options-connectors/page-wp-admin.php` |

Enqueue scripts and styles for the options-connectors-wp-admin page.

  | 
| [wp_options_connectors_render_page()](https://developer.wordpress.org/reference/functions/wp_options_connectors_render_page/)`wp-includes/build/pages/options-connectors/page.php` |

Render the options-connectors page.

  | 
| [wp_font_library_render_page()](https://developer.wordpress.org/reference/functions/wp_font_library_render_page/)`wp-includes/build/pages/font-library/page.php` |

Render the font-library page.

  | 
| [wp_font_library_wp_admin_enqueue_scripts()](https://developer.wordpress.org/reference/functions/wp_font_library_wp_admin_enqueue_scripts/)`wp-includes/build/pages/font-library/page-wp-admin.php` |

Enqueue scripts and styles for the font-library-wp-admin page.

  | 
| [wp_enqueue_img_auto_sizes_contain_css_fix()](https://developer.wordpress.org/reference/functions/wp_enqueue_img_auto_sizes_contain_css_fix/)`wp-includes/media.php` |

Enqueues a CSS rule to fix potential visual issues with images using `sizes=auto`.

  | 
| [WP_Interactivity_API::data_wp_router_region_processor()](https://developer.wordpress.org/reference/classes/wp_interactivity_api/data_wp_router_region_processor/)`wp-includes/interactivity-api/class-wp-interactivity-api.php` |

Processes the `data-wp-router-region` directive.

  | 
| [wp_enqueue_emoji_styles()](https://developer.wordpress.org/reference/functions/wp_enqueue_emoji_styles/)`wp-includes/formatting.php` |

Enqueues the important emoji-related styles.

  | 
| [wp_enqueue_embed_styles()](https://developer.wordpress.org/reference/functions/wp_enqueue_embed_styles/)`wp-includes/embed.php` |

Enqueues the CSS in the embed iframe header.

  | 
| [WP_Duotone::output_footer_assets()](https://developer.wordpress.org/reference/classes/wp_duotone/output_footer_assets/)`wp-includes/class-wp-duotone.php` |

Outputs all necessary SVG for duotone filters, CSS for classic themes.

  | 
| [wp_enqueue_stored_styles()](https://developer.wordpress.org/reference/functions/wp_enqueue_stored_styles/)`wp-includes/script-loader.php` |

Fetches, processes and compiles stored core styles, then combines and renders them to the page.

  | 
| [_wp_theme_json_webfonts_handler()](https://developer.wordpress.org/reference/functions/_wp_theme_json_webfonts_handler/)`wp-includes/deprecated.php` |

Runs the theme.json webfonts handler.

  | 
| [wp_enqueue_global_styles_css_custom_properties()](https://developer.wordpress.org/reference/functions/wp_enqueue_global_styles_css_custom_properties/)`wp-includes/script-loader.php` |

Function that enqueues the CSS Custom Properties coming from theme.json.

  | 
| [wp_enqueue_block_style()](https://developer.wordpress.org/reference/functions/wp_enqueue_block_style/)`wp-includes/script-loader.php` |

Enqueues a stylesheet for a specific block.

  | 
| [wp_enqueue_global_styles()](https://developer.wordpress.org/reference/functions/wp_enqueue_global_styles/)`wp-includes/script-loader.php` |

Enqueues the global styles defined via theme.json.

  | 
| [register_block_style_handle()](https://developer.wordpress.org/reference/functions/register_block_style_handle/)`wp-includes/blocks.php` |

Finds a style handle for the block metadata field.

  | 
| [wp_enqueue_registered_block_scripts_and_styles()](https://developer.wordpress.org/reference/functions/wp_enqueue_registered_block_scripts_and_styles/)`wp-includes/script-loader.php` |

Enqueues registered block scripts and styles, depending on current rendered context (only enqueuing editor scripts while in context of the editor).

  |

[Show 11 more](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | A return value was added. | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#comment-content-1243)
 2.    [Ivan Shulev](https://profiles.wordpress.org/ishulev/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_register_style/#comment-1243)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-1243)
     Vote results for this note: 6[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-1243)
 4.  **Examples**
      In a Plugin (outside a PHP class)
 5.   Assumes the Plugin directory is named ‘my-plugin’.
      Assumes the Plugin style 
     sheet is named ‘plugin.css’.
 6.      ```php
         /**
          * Registers a stylesheet.
          */
         function wpdocs_register_plugin_styles() {
         	wp_register_style( 'my-plugin', plugins_url( 'my-plugin/css/plugin.css' ) );
         	wp_enqueue_style( 'my-plugin' );
         }
         // Register style sheet.
         add_action( 'wp_enqueue_scripts', 'wpdocs_register_plugin_styles' );
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%3Freplytocom%3D1243%23feedback-editor-1243)
 8.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#comment-content-1244)
 9.    [Ivan Shulev](https://profiles.wordpress.org/ishulev/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_register_style/#comment-1244)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-1244)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-1244)
 11. **Example**
      In a plugin (inside a PHP class)
 12.  Assumes the Plugin class name is ‘my_plugin’.
      Assumes the Plugin directory is
     named ‘my-plugin’. Assumes the Plugin style sheet is named ‘plugin.css’.
 13.     ```php
         class WPDocs_My_Plugin_Stylesheet {
     
         	/**
         	 * Constructor.
         	 */
         	function __construct() {
         		// Register stylesheet.
         		add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );
         	}
     
         	/**
         	 * Registers and enqueues stylesheet.
         	 */
         	public function register_plugin_styles() {
         		wp_register_style( 'my-plugin', plugins_url( 'my-plugin/css/plugin.css' ) );
         		wp_enqueue_style( 'my-plugin' );
         	}
         }
         new WPDocs_My_Plugin_Stylesheet();
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%3Freplytocom%3D1244%23feedback-editor-1244)
 15.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/wp_register_style/?output_format=md#comment-content-5464)
 16.   [crstauf](https://profiles.wordpress.org/crstauf/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/wp_register_style/#comment-5464)
 17. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-5464)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%23comment-5464)
 18. Note that Google Fonts has changed their URLs, so when embedding multiple font
     families only one will be loaded. The change is “fundamentally incompatible with
     how the rest of the world uses query variables and thus PHP itself”.
 19. The fix is to set `null` on the `$version` parameter, which prevents the URL from
     being parsed and the additional font families lost.
 20. Trac ticket: [https://core.trac.wordpress.org/ticket/49742](https://core.trac.wordpress.org/ticket/49742)
 21.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F%3Freplytocom%3D5464%23feedback-editor-5464)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_style%2F)
before being able to contribute a note or feedback.