Do you want to add custom styles to WordPress widgets?
Styling your widgets allows you to keep your branding consistent and highlight important information for your users.
In this article, we’ll show you how to easily add custom styles to WordPress widgets without breaking your website.
We’ll show you three ways to add custom styles to WordPress widgets. You can pick one that works best for you.
- Adding Custom Styles to WordPress Widgets Using Block Editor
- Adding Custom Styles to Classic Widgets in WordPress
- Adding Custom Styles to WordPress Widgets Using CSS Hero (no code)
Before we begin, this article requires some CSS knowledge so you can style widgets. You’ll also need to add custom CSS to your WordPress theme.
If you’d prefer a no-code method instead of CSS, you can skip to method 3.
Let’s get started.
Adding Custom Styles to WordPress Widgets using Block Editor
WordPress widgets now use the block editor to add widgets and blocks to widget-ready areas and sidebars.
One of the advantages of using the block editor for widgets is that you can easily add custom CSS classes to each block.
Simply go to the Appearance » Widgets page and 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.
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.
Note: If you can’t see Customize under Appearance Menu, then take a look at our article on how to fix missing theme customizer in WordPress admin or use the WPCode plugin to add your custom CSS.
Here is some basic CSS we used.
.latest-articles {
background-color:#def4f1;
padding:10px;
}
After adding your custom CSS, you can preview your website to see it in action.
The problem with using the block editor widgets is finding the right block to target.
An easier fix would be to add blocks into a Group block to easily style them together. You can read more about grouping blocks in our guide on how to use the WordPress block editor.
Adding Custom Styles to Classic Widgets in WordPress
This method is for you if you use the older classic widgets on your WordPress website.
For this method, you need to install and activate the Widget Options plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Widget Options is a powerful plugin that adds extra options to your WordPress widgets. This includes the ability to show and hide widgets based on the user device, role, and other conditions.
The plugin also adds an option to add custom CSS classes to your WordPress widgets.
Simply go to the Appearance » Widgets page and click on the widget where you want to add the custom style.
In Widget settings, you’ll see an extended range of options. From here, you need to click on the Gear icon to add your custom CSS class.
Once you are finished, don’t forget to click on the Save button to store your widget settings.
You can now add custom CSS rule to your theme using the CSS class you just entered. For instance, we used the following CSS on our test site.
.latest-articles {
background-color:#def4f1;
padding:10px;
}
This is how it looked on our test website.
Applying Custom Styles to WordPress Widgets With CSS Hero
One problem with the above two methods 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.
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.
This will open the page in 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.
Simply take your mouse over to the widget that you want to style and click to select it.
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.
Once you are finished, don’t forget to Save button to store your settings.
You can now preview your website to see your changes in action.
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 most useful WordPress widgets for all websites or see our guide on creating custom WordPress theme from scratch without writing code.
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.
Ankush says
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…
Rachael says
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?
Regina says
Does how to instructional above also also include the ability to customize the font of the widget titles?
Thanks!
terry says
Finally, after failing at trying to decode the jargon I get on inspect, this article told me exactly what I needed.
Thanks
Alex says
I don’t have any classes on widgets.
irfan says
There is extra white space while creating extra widget area for header. Kindly tell us , how to remove this
Thomas says
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?
WPBeginner Support says
Hey Thomas,
Please take a look at this guide on how to add custom css to WPForms.
Admin
daniel says
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.
WPBeginner Support says
Hey Daniel,
You’ll need to use place the widget code before your menu and then add custom CSS to position it.
Admin
Deniz Kumru says
It’s my first wordpress theme.I was nervous till found your article.It’s done thank you
ivan says
Why does my layout under widget styles only shows the padding option, without the bottom margin, gutter & row layout option.
Rimi says
hallo
I can not make any changes because it is inactive
Being processed plugin / css / plugin-front.css (inactive),How can I activate pleas
Grace says
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 says
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
Mr.T says
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 says
I have the same question
Correen K says
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
Abhishek Prakash says
Will using these many CSS not impact the page speed?
WPBeginner Staff says
Not if you do it right.