How to add a CSS in WordPress?

How to add a CSS in WordPress?

Here are three methods on how you can add a CSS in WordPress.

First option: The standard and static way of adding a link between your stylesheet and html file.

Add the following to your HTML code.

Inside the

of your HTML.


1. css/style.css is only an example directory and file. It may be different on your case, it is dependent on your actual stylesheet directory and file name.
2. For JS, the code should be . Similar with note #1, js/code.js is only an example directory and file.

Second option: Add an @import in your CSS file. Example In your CSS file, add the code above. @import ‘css/bootstrap.min.css’;

Third option: Create a functions.php in your selected WordPress theme folder with the following script.


function THEMENAME_script_enqueue() {
     wp_enqueue_style('stylename', get_template_directory_uri() . '/css/style.css');
     wp_enqueue_script('jsname', get_template_directory_uri() . '/js/code.js');
add_action( 'wp_enqueue_scripts', 'THEMENAME_script_enqueue');

1. THEMENAME should be replaced with the actual theme folder name.
2. wp_enqueue_script is an additional code where in you add javascript files within your WordPress project. It is not mandatory.
3. You need to add wp_head() in the

section of your HTML and add wp_footer() before the end of your tag to make sure that the scripts are added to your HTML structure.