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

How to Add Custom Styles to WordPress Widgets (2 Ways)

Customizing your widgets is a powerful way to enhance your website’s appearance, maintain brand consistency, and draw attention to important information.

However, many WordPress users find widget styling challenging, especially if they’re not comfortable with CSS. Don’t worry, though, because we’re here to help.

In this article, we’ll show you two easy methods to add custom styles to WordPress widgets without breaking your website. Whether you’re comfortable with a bit of CSS or prefer a no-code solution, we’ve got you covered.

Adding custom styles to WordPress widgets

We’ll show you 2 ways to add custom styles to WordPress widgets. You can use these quick links to skip to the one that works best for you:

Note: This article is intended for classic theme users. If you use a block theme, then you won’t see the Widgets or Theme Customizer pages on your admin. You will have to use blocks and the full-site editor to customize your theme.

For more information, check out our beginner’s guide to WordPress full-site editing.

Method 1: Adding Custom Styles to WordPress Widgets With Block Editor (Basic)

WordPress widgets now use the block editor to add widgets and blocks to widget-ready areas and sidebars. That means, you will see some block styling options for some of the default WordPress blocks.

For example, if you go to the Appearance » Widgets page and click on a default WordPress block, you will see options to change the block’s colors and typography.

The default WordPress widget styling options

However, not all blocks come with this option, especially if these blocks are not default WordPress ones. Thankfully, one of the advantages of using the block editor for widgets is that you can easily add custom CSS classes to each block.

All you need to do is simply click on the widget where you want to add custom styles.

Next, you need to scroll down to the ‘Advanced’ tab under the Block panel. From here, you can add a custom CSS class.

Adding custom CSS class to widgets in Block Editor

Don’t forget to save your changes by clicking on the ‘Update’ button.

Now, you can add custom CSS to your WordPress theme targeting that particular CSS class.

Simply go to Appearance » Customize page and switch to the Additional CSS tab. There, you will see a live preview of your website with a box to add your CSS rules.

Add CSS rules

Another way to add custom CSS is with WPCode. We recommend using this if you have a lot of custom CSS code already in your theme and want to easily differentiate and track all of the snippets.

First, make sure to install the WPCode plugin. For step-by-step instructions, you can read our guide on how to install a WordPress plugin.

Next, go to Code Snippets » + Add Snippet and select ‘Add Your Custom Code (New Snippet). Then, click the ‘+ Add Custom Snippet’ button.

Adding a new custom code snippet in WPCode

Now, give your new custom CSS a name. It can be something simple like ‘Custom Widget Style.’

Then, change the Code Type to ‘CSS Snippet.’

Custom CSS to style WordPress widgets

Next, go ahead and add your custom CSS in the field.

Here is some basic CSS we used:

.latest-articles { 
background-color:#def4f1;
padding:10px;
}

Once done, just scroll down to the Insertion section. Make sure the Insert Method is set to ‘Auto Insert’ and the Location is ‘Site Wide Header.’

After that, toggle the button at the top right corner until it says ‘Active’ and click ‘Save Snippet.’

Choosing Site Wide Header as the code location in WPCode

After adding your custom CSS, you can view your website on mobile or desktop to see it in action.

Here’s what ours looks like:

Block widget with custom style preview

Method 2: Applying Custom Styles to WordPress Widgets With CSS Hero (More Customizable)

One problem with the above method is that you need to write CSS code. However, not all users know CSS or just don’t want to write code themselves.

In that case, you can use CSS Hero. It is a custom WordPress styling plugin that allows you to add custom CSS to your WordPress theme without writing any code.

You can learn more about the plugin in our CSS Hero review.

First, you need to install and activate the CSS Hero plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, the plugin will add a new menu item to your WordPress admin toolbar at the top.

Next, you need to visit the page where you can see the widget you want to style and click on the CSS Hero button at the top.

Opening CSS Hero in WordPress

This will open the page in the CSS Hero editor interface.

It is a live editor where you can simply point and click on any item on your website and change its style.

CSS Hero interface

Simply take your mouse over to the widget that you want to style. Then, click to select it.

In this example, we selected our Search widget.

Clicking on a search widget in CSS Hero

After that, you can use the menu on the left to style your widget any way you want. This includes advanced styling options like gradients, typography, padding, margins, and borders.

In the example below, we changed the font size of the Search widget so that it stands out even more.

Changing a search widget's typography in CSS Hero

You can also change specific elements of the widget if needed.

For instance, we decided to change the border radius of the button and search fields. This way, they look more curved and stylish.

Changing a search widget's border radius in CSS Hero

Once you are finished, don’t forget to click the ‘Save’ button to store your settings.

Then, go ahead and preview your website to see your changes in action.

Clicking the Save button in CSS Hero

We hope this article helped you learn how to add custom styles to WordPress widgets. You may also want to see our pick of the best drag-and-drop page builders for WordPress and our pros and cons comparison between free vs premium WordPress themes.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

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!

Reader Interactions

20 CommentsLeave a Reply

  1. Ankush

    The Plugin was really Great but I had a problem…

    It doesn’t work when i add custom css….

    May be plugin css is overriding my code but.. that really sad…

    Hey Wpbeginner.com Team.. Please leave me a reply,]

    I You can tell me how to fix it…

  2. Rachael

    I love this plugin but every time I activate it, I have trouble with the gallery widget. It works fine with the plugin deactivated, but if I turn on the plugin, the gallery widget won’t save any images. All of the other widgets work fine. Does anyone else have this issue?

  3. Regina

    Does how to instructional above also also include the ability to customize the font of the widget titles?
    Thanks!

  4. terry

    Finally, after failing at trying to decode the jargon I get on inspect, this article told me exactly what I needed.

    Thanks

  5. Alex

    I don’t have any classes on widgets.

  6. irfan

    There is extra white space while creating extra widget area for header. Kindly tell us , how to remove this

  7. Thomas

    Hi, I tried to do it manually, inspected the element and its class but it did not work.

    I am trying to change the style of a WPform.

    Could you help me?

  8. daniel

    i have added a widget area to my header using the functions.php and header.php files. i can see the widget ive added on my site but i want to put it next to the menu, any idea how to do this please? i want it to sit to the right hand side of the menu.

  9. Deniz Kumru

    It’s my first wordpress theme.I was nervous till found your article.It’s done thank you :)

  10. ivan

    Why does my layout under widget styles only shows the padding option, without the bottom margin, gutter & row layout option.

  11. Rimi

    hallo
    I can not make any changes because it is inactive
    Being processed plugin / css / plugin-front.css (inactive),How can I activate pleas

  12. Grace

    Hello, my theme doesn’t have a right sidebar, it came with just a footer widget area, can I use the custom css to add a right sidebar? Please help me, thanks

    • WPBeginner Support

      No, you will first need to define a widget ready area. Your theme may already have an option to use a sidebar layout. If it doesn’t, then we would recommend you to ask the theme author for support. On the other hand, if you feel confident in your coding skills, then go a head.

      Admin

  13. Mr.T

    I want to change them manually. Am I right that by using widget-number class you actually can’t move them up or down in the widgets area, because their id will change, or it works differently?

    • Erick

      I have the same question

  14. Correen K

    I was looking for something like this to add some style to my sidebar and stumbled upon the Flexible Posts Widget plugin. I think it’s always nice to have options ;)

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.