Use WP Enqueue Style To Properly Add CSS Files To WordPress

Updated June 10th, 2020
Share this post:

Paste the code below into your functions.php file.

Then, replace PATH TO CSS FILE with the absolute or relative URL to the CSS file you want to include.

function enqueue_my_custom_styles() {
    wp_enqueue_style( 'my-custom-css', 'PATH TO CSS FILE', false ); 
}

add_action( 'wp_enqueue_scripts', 'enqueue_my_custom_styles' );
Share this post:

Responses

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

  1. Hey Bjorn, BIG thanks of an excellent tutorial.

    Can you please clarify:
    In the code you supply, I noticed that the wp_enqueue_style line and the add_action line, both contain the words “my-custom-css”

    In the YouTube tutorial you changed ‘my-custom-css’ to “animate.min.css”
    But you did not change the add_action line.

    Can you please confirm that we do not need to edit the add_action line so that it matches whatever name we enter in the wp_enqueue_style line?

    Thanks,
    Julian

WPLearningLab