Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

What is: CSS

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

CSS (Cascading Style Sheets) is a language with a set of rules that define how the elements on your website look.

These rules control your website’s design elements, such as the font size and color, the background color of your site, and how much space there is between different sections.

Think of CSS as the styling instructions for your website. While your WordPress theme uses HTML elements to structure the content of your site (like headings, paragraphs, images, and buttons), CSS tells the browser how to visually present those elements.

What Is CSS in WordPress

Why Would You Need to Edit CSS in WordPress?

While WordPress themes offer a variety of design options, you might sometimes want to make specific changes to your website’s appearance beyond the theme’s built-in settings. This is where editing CSS comes in handy for WordPress users.

For example, you may want to change the background color of a specific section on your website or slightly tweak the font size for better readability.

You can also personalize your website’s appearance and differentiate it from other sites using the same theme. This could involve changing the text selection color, adding a parallax effect, or styling the WordPress comment form.

Parallax effect GIF

Sometimes, a theme might not display elements exactly as you want in your web design. With a few lines of CSS, you can fix minor issues like centering text that appears off-center or adjusting the padding or margin around an image.

Do I Need to Know CSS to Use WordPress?

No, you don’t necessarily need to know CSS to build a WordPress website. Most WordPress themes come with a variety of built-in design options that allow you to customize the look and feel of your site without touching any code.

CSS editing is typically considered an advanced feature. While beginners can certainly use WordPress without it, knowing CSS opens up more possibilities for fine-tuning your website’s design.

To make CSS editing easier, you can use a WordPress plugin like CSS Hero. A CSS plugin gives you a visual approach to making CSS changes and is compatible with many popular WordPress themes.

CSS code preview

That said, understanding how CSS works will give you more control and flexibility in customizing your WordPress website.

Basics of CSS in WordPress (With Examples)

CSS uses a specific syntax to define how elements on your website should look. While it might seem complex at first, the basic structure is quite simple.

The first thing you should know about is CSS selectors. These tell CSS which elements on your website to style. They are like labels pointing to specific parts of your website.

For example, the body tag refers to the entire content area of your website. So, the selector body would target the entire page.

The second is properties. These define the specific visual aspects you want to change. Properties are like instructions for how you want the selected element to look. Common examples include color, font-size, background-color, and margin.

Next is values. These specify what the property should be set to. For example, the value for color could be red, blue, or a specific color code.

Then, there is the CSS class, which is a type of attribute that can be assigned to HTML elements. You can assign a class to an element in the HTML code and then use it in your CSS to apply the same styles to all elements with that class.

Let’s say you want to change the background color of your entire website to black. Here’s the CSS code for that:

body {
  background-color: black;

In this example:

  • body is the selector, targeting the entire website content area.
  • background-color is the property, defining what aspect we want to change.
  • black is the value specifying the new background color.

Now, suppose you want to highlight certain text on your website. You could create a CSS class called .highlight that makes the text bold and changes its color to yellow. Here’s how you would define that class in your CSS:

.highlight {
 font-weight: bold;
 color: yellow;

And here’s how you would apply it to elements in your HTML:

<p class="highlight">This text will be highlighted.</p>
<div class="highlight">This div will also be highlighted.</div>

In this example:

  • .highlight is the class selector. It selects all elements with the class “highlight”.
  • font-weight: bold; and color: yellow; are properties. They define what aspects of the selected elements we want to change.
  • bold and yellow are values. They specify the new values for the properties.

How Can I Add Custom CSS Code to WordPress?

How you can add custom CSS depends on what kind of WordPress theme you’re using.

If you use a classic theme, then you can go to the WordPress customizer and select ‘Additional CSS’ to add your code there.

Additional CSS in Theme Customizer

If you use a block WordPress theme, then the theme customizer will be missing from your WordPress dashboard. This is because your default editor is now the full-site editor.

That being said, you can still access the WordPress customizer by adding /wp-admin/customize.php at the end of your domain name like this:

When you add custom CSS through the WordPress customizer, the changes are stored in the WordPress database, not in the physical style.css file (your theme’s stylesheet).

This approach allows you to make changes without directly editing the theme files, which is a much safer method.

That said, you cannot make complex CSS changes this way. So, the alternative is to use a code snippet plugin like WPCode, as it can safely insert custom CSS into your WordPress theme.

Paste custom CSS code and select CSS Snippet as the Code Type

You can also create a child theme and add your custom CSS code there. This way, your CSS tweaks will still be there even when the parent theme is updated.

For more information, you can read our step-by-step guide on how to add custom CSS to your WordPress site.

Lastly, you can also use a CSS editor plugin like CSS Hero. This plugin lets you edit CSS without knowing how to code. Check out our CSS Hero review for more information.

Why Is My CSS Not Showing on My WordPress Site?

Your CSS may not be showing on your WordPress site because of syntax errors. A small mistake in your CSS code can prevent it from being applied. This could be a missing bracket, a typo in a property name, or an incorrect value.

Additionally, if you’ve recently added or changed your CSS, then you might need to clear your cache to see the changes. Clear your browser’s cache and, if you are using a caching plugin on your WordPress site, then you should clear that as well.

Sometimes, other themes or plugins can interfere with your CSS. Try deactivating other plugins one by one to see if the issue resolves. If it does, the last plugin you deactivated is likely causing the conflict.

If you are using a child theme and your CSS isn’t showing up, ensure that the child theme is correctly set up and that the CSS file is correctly enqueued in the functions.php file of the child theme.

If you need help, you can check out our beginner’s guide to troubleshooting WordPress errors.

We hope this article helped you learn more about CSS in WordPress. You may also want to see our Additional Reading list below for related articles on useful WordPress tips, tricks, and ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Additional Reading

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!