Scale your business with our modular plugins.
Home » Blog » Best CSS Codes to Customize WordPress Websites

Best CSS Codes to Customize WordPress Websites

best css codes to customize wordpress websites
March 15, 2022||By Jane F

Are you looking for the best CSS codes to customize WordPress websites? If so, keep reading this article.

Want to take your WordPress website’s design to the next level without installing dozens of plugins?

Adding custom CSS is one of the most efficient ways to personalize your site’s appearance, improve user experience, and maintain complete control over every visual element.

CSS allows you to adjust fonts and colors, tweak layout spacing, and style buttons, opening the door to almost limitless design possibilities.

In this guide, we’ll show you how to add custom CSS to your WordPress site and share a collection of useful CSS code snippets to help you create a clean, modern, and fully customized website.

Whether you’re a beginner or an experienced user, this post will help you make your site your own, with just a few lines of code.

Why You Should Add Custom CSS Codes to Customize WordPress Websites?

Adding custom CSS codes to your WordPress site gives you greater control over its design and functionality.

While themes and page builders offer preset styles, they often have limitations. Custom CSS allows you to break free from those constraints and tailor every visual aspect of your website exactly how you want it.

With CSS, you can adjust spacing, colors, typography, and layout elements without relying on third-party plugins.

This can lead to a cleaner, faster website since you’re not loading extra resources. It’s also a great way to ensure your site maintains a consistent brand identity across all pages.

Whether making minor design tweaks or implementing full layout changes, custom CSS helps you create a more polished and professional-looking website.

How to Add Custom CSS in WordPress?

There are several ways to add custom CSS to your WordPress website, depending on your comfort level and the tools you prefer to use. Here are the most common methods:

  • Using the WordPress Customizer
    • Go to Appearance > Customize > Additional CSS. This is the simplest way to add custom CSS. You can see the changes in real-time before publishing.
  • With a Custom CSS Plugin
    • Install a dedicated plugin to manage your CSS separately from your theme. This is ideal if you want to keep customizations even when switching themes.
  • By Creating a Child Theme
    • A child theme is the safest way for more advanced users to add custom CSS and make other code changes. This ensures updates to the parent theme won’t overwrite your customizations.
  • Directly in the Theme’s Style.css File
    • You can add CSS to your theme’s style.css file via FTP or the Theme File Editor. However, this method is not recommended unless you use a child theme, as updates to the parent theme will erase your changes.

Essential CSS Codes to Customize WordPress

In a nutshell, these are the things we are going to do with the CSS codes:

  • Change the site’s font style and size
  • Style headings for better readability
  • Customize paragraph spacing and line height
  • Style default WordPress buttons
  • Add hover effects to buttons
  • Center-align the site title
  • Remove underlines from links
  • Add hover color effects to links
  • Style the navigation menu items
  • Highlight the current menu item
  • Change the header background color
  • Adjust footer padding and layout
  • Hide the footer credit section
  • Customize widget title styles
  • Add box shadow and padding to widgets
  • Style input fields and text areas
  • Add borders and rounded corners to images
  • Apply hover effects to images
  • Make fonts responsive for mobile devices
  • Hide elements on mobile view
  • Hide category metadata from posts
  • Hide the author information section

Below, we will show you which code can help you with these customizations. Without any further ado, let’s get to the tutorial.

1. Change the site’s font style and size

Customizing your WordPress site’s font style and size helps create a unique look and improves readability. You can easily do this by adding CSS code to your site.

Add the following CSS to your Additional CSS area or child theme stylesheet:

body {
font-family: 'Arial', sans-serif; /* Change to your preferred font */
font-size: 16px; /* Adjust font size as needed */
line-height: 1.6; /* Improves readability */
color: #333333; /* Customize text color */
}

Replace ‘Arial’, sans-serif with any web-safe font or Google Fonts you choose. You can adjust the font size and color to match your branding and design preferences. This CSS will apply globally to all the text on your site.

You can target their CSS selectors separately to style specific elements like headings or menus.

2. Style headings for better readability

Well-styled headings improve the structure and readability of your WordPress site. Using CSS, you can customize font size, weight, color, and spacing to make headings stand out clearly.

Add this CSS to your Additional CSS area or child theme stylesheet:

h1, h2, h3, h4, h5, h6 {
font-family: 'Georgia', serif; /* Choose a clear, readable font */
color: #222222; /* Dark color for good contrast */
font-weight: 700; /* Bold headings */
line-height: 1.3; /* Tight line spacing */
margin-bottom: 15px; /* Space below headings */
}

Adjust the font family, size, or color to match your site’s style. Clear, consistent headings help visitors scan your content and improve overall user experience.

3. Customize paragraph spacing and line height

Proper paragraph spacing and line height improve your WordPress content’s readability and visual flow.

You can easily adjust these using CSS. Add this CSS to your Additional CSS area or child theme stylesheet:

p {
margin-bottom: 20px; /* Space after each paragraph */
line-height: 1.6; /* Space between lines for easier reading */
}

Adjust the margin-bottom value to control the space between paragraphs, and modify line-height to increase or decrease the spacing between lines within paragraphs.

Consistent spacing helps readers follow your content comfortably, especially on longer posts or pages.

4. Style default WordPress buttons

Customizing the appearance of your site’s buttons can improve user interaction and overall design.

You can easily style default WordPress buttons using CSS. Add this CSS to your Additional CSS area or child theme stylesheet:

button,
input[type="button"],
input[type="submit"],
.wp-block-button__link {
background-color: #0073aa; /* Button background color */
color: #ffffff; /* Text color */
padding: 12px 24px; /* Button padding */
border: none; /* Remove default border */
border-radius: 5px; /* Rounded corners */
font-size: 16px; /* Font size */
cursor: pointer; /* Pointer cursor on hover */
transition: background-color 0.3s ease; /* Smooth hover transition */
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
.wp-block-button__link:hover {
background-color: #005177; /* Darker background on hover */
}

This CSS targets standard WordPress buttons, including block editor buttons. Adjust colors, padding, and font size to fit your theme’s style.

5. Add hover effects to buttons

Hover effects can make your buttons more interactive and visually engaging, improving the user experience on your WordPress site.

Add this CSS to your Additional CSS area or child theme stylesheet:

button,
input[type="button"],
input[type="submit"],
.wp-block-button__link {
background-color: #0073aa;
color: #ffffff;
padding: 12px 24px;
border: none;
border-radius: 5px;
transition: all 0.3s ease;
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
.wp-block-button__link:hover {
background-color: #005177;
transform: scale(1.05); /* Slight zoom on hover */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* Subtle shadow effect */
}

These hover effects make buttons feel more dynamic and clickable. You can customize the colors, scale, and shadow intensity to fit your design.

6. Center align the site title

If your WordPress theme doesn’t center the site title by default, you can easily adjust its alignment using CSS for a more balanced look.

Add this CSS to your Additional CSS area or child theme stylesheet:

.site-title {
text-align: center;
display: block;
margin: 0 auto;
}

This rule targets the .site-title class and centers it within its container. Ensure your theme uses this class, or inspect your site’s HTML to adjust the selector accordingly.

7. Remove underlines from links

You can remove the default underline styling using CSS to give your links a cleaner look. Add this CSS to your Additional CSS area or child theme stylesheet:

a {
text-decoration: none;
}
a:hover {
text-decoration: underline; /* Optional: show underline on hover */
}

This removes the underline from all links by default and optionally adds it back on hover to maintain good usability. You can modify the hover effect to suit your design preferences.

8. Add hover color effects to links

Enhancing your links with hover color effects improves interactivity and draws attention to clickable elements.

Add this CSS to your Additional CSS area or child theme stylesheet:

a {
color: #0073aa;
text-decoration: none;
transition: color 0.3s ease;
}
a:hover {
color: #005177; /* Darker shade on hover */
text-decoration: underline; /* Optional */
}

This CSS smoothly changes the link color when a user hovers over it. You can customize the colors and transition speed to match your design preferences.

9. Style the navigation menu items

Customizing your navigation menu can significantly enhance your site’s look and feel. Use CSS to style menu items with padding, spacing, hover effects, and more.

Add this CSS to your Additional CSS area or child theme stylesheet:

.main-navigation a,
.nav-menu a,
.menu-item a {
color: #333333;
text-transform: uppercase;
font-weight: 600;
padding: 10px 15px;
text-decoration: none;
transition: background-color 0.3s ease, color 0.3s ease;
}
.main-navigation a:hover,
.nav-menu a:hover,
.menu-item a:hover {
background-color: #0073aa;
color: #ffffff;
border-radius: 4px;
}

This styling adds padding for better spacing, bold uppercase text for clarity, and a hover effect that changes the background and text color. Adjust the selectors if your theme uses different class names.

10. Highlight the current menu item

To help visitors know which page they are on, you can style the current menu item differently with CSS. Add this CSS to your Additional CSS area or child theme stylesheet:

.main-navigation .current-menu-item > a,
.nav-menu .current-menu-item > a,
.menu-item.current-menu-item > a {
background-color: #005177;
color: #ffffff;
font-weight: 700;
border-radius: 4px;
}

This code highlights the active menu item with a distinct background color, white text, and slightly bolder font for better visibility. Adjust the colors to match your site’s theme.

11. Change the header background color

With a simple CSS snippet, you can easily update your site’s header background color to match your branding or improve visual appeal.

Add this CSS to your Additional CSS area or child theme stylesheet:

.site-header,
.header,
.site-header-wrap {
background-color: #0073aa; /* Replace with your desired color */
}

Adjust the color code to any hex, RGB, or named color you prefer. Check your theme’s header class if these selectors don’t work, and modify accordingly.

12. Adjust footer padding and layout

Proper footer spacing and layout improve the overall balance and readability of your website’s bottom section. Use this CSS to customize padding and arrange footer elements neatly.

Add this CSS to your Additional CSS area or child theme stylesheet:

.site-footer,
.footer-widgets,
.footer {
padding: 40px 20px; /* Adjust top/bottom and left/right padding */
background-color: #f8f8f8; /* Optional: change footer background */
display: flex;
flex-wrap: wrap;
justify-content: space-between; /* Distribute widgets evenly */
gap: 20px; /* Space between footer items */
}
.footer-widgets .widget {
flex: 1 1 200px; /* Flexible width, minimum 200px */
margin-bottom: 20px;
}

You can modify the padding values and layout properties to suit your design preferences. This setup keeps footer widgets responsive and well-spaced on all screen sizes.

13. Hide the footer credit section

Many WordPress themes include a footer credit like “Proudly powered by WordPress.” You can hide this section with a simple CSS snippet.

Add this CSS to your Additional CSS area or child theme stylesheet:

.site-info,
.footer-credit,
.footer .site-info {
display: none;
}

This targets common class names used for footer credits in popular themes. If it doesn’t work, inspect your theme’s footer element and adjust the selector accordingly.

14. Customize widget title styles

Styling widget titles helps improve readability and gives your sidebar or footer a more polished and consistent look.

Add this CSS to your Additional CSS area or child theme stylesheet:

.widget-title,
.sidebar .widget h2,
.footer-widgets .widget h2 {
font-size: 20px;
font-weight: 700;
color: #333333;
text-transform: uppercase;
border-bottom: 2px solid #0073aa;
padding-bottom: 8px;
margin-bottom: 15px;
}

You can adjust the font size, color, and border style to match your site’s theme better. This CSS targets common widget title elements found in most themes.

15. Add box shadow and padding to widgets

Enhancing your WordPress widgets with box shadows and padding gives them a cleaner, more professional look. It helps separate widget content visually and improves layout aesthetics.

Add this CSS to your Additional CSS area or child theme stylesheet:

.widget {
padding: 20px; /* Inner spacing */
background-color: #ffffff; /* Optional background */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Soft shadow effect */
border-radius: 8px; /* Rounded corners (optional) */
margin-bottom: 20px; /* Space between widgets */
}

You can modify the shadow strength, padding size, and colors to match your theme. These styles help widgets stand out without being too flashy.

16. Style input fields and text areas

Customizing the look of input fields and text areas can enhance the form appearance on your WordPress site, making it more user-friendly and visually appealing.

Add this CSS to your Additional CSS area or child theme stylesheet:

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
border: 2px solid #ccc; /* Border color */
border-radius: 6px; /* Rounded corners */
padding: 10px 12px; /* Inner spacing */
font-size: 16px; /* Text size */
width: 100%; /* Full width for responsiveness */
box-sizing: border-box; /* Include padding and border in width */
transition: border-color 0.3s ease; /* Smooth transition on focus */
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
border-color: #0073aa; /* Highlight border on focus */
outline: none; /* Remove default outline */
box-shadow: 0 0 5px rgba(0, 115, 170, 0.5); /* Subtle glow */
}

Feel free to adjust colors, padding, and font sizes to fit your site’s design and improve user experience when filling out forms.

17. Add borders and rounded corners to images

Adding borders and rounded corners to images can enhance the visual appeal of your WordPress site by giving images a polished, stylish look.

You can easily achieve this with CSS. Add the following code to your Additional CSS area or child theme stylesheet:

img {
border: 3px solid #ccc; /* Light gray border around images */
border-radius: 10px; /* Rounded corners */
padding: 5px; /* Optional padding inside the border */
box-sizing: border-box; /* Ensures padding and border are included in total size */
}

Feel free to adjust the border color, thickness, and radius to match your site’s design. Rounded corners soften the image edges and make your content look more modern and cohesive.

18. Apply hover effects to images

Adding hover effects to images enhances user interaction and makes your WordPress site more engaging. On hover, you can apply simple CSS effects like zoom, opacity change, or grayscale.

Add the following CSS to your Additional CSS area or child theme stylesheet:

img:hover {
transform: scale(1.05); /* Slight zoom on hover */
transition: transform 0.3s ease;
opacity: 0.9; /* Slight fade effect */
}

You can customize the effect by adjusting the scale, opacity, or adding other styles like grayscale or shadow:

img:hover {
filter: grayscale(50%);
transition: filter 0.3s ease;
}

Use browser developer tools to target specific image classes if you want hover effects on particular images only.

19. Make fonts responsive for mobile devices

Ensuring your website’s fonts adapt smoothly across different screen sizes is essential for readability and a great user experience. You can make your fonts responsive in WordPress using CSS media queries.

Add the following CSS to your Additional CSS area or child theme stylesheet:

body {
font-size: 16px; /* Default desktop font size */
}
@media only screen and (max-width: 768px) {
body {
font-size: 14px; /* Smaller font size for mobile devices */
}
}

You can adjust the font sizes to fit your design preferences. This CSS reduces the font size on screens narrower than 768px, making text easier to read on mobile devices without overwhelming the layout.

For more precise control, you can target specific elements like headings, paragraphs, or menus using their selectors inside the media query.

20. Hide elements on mobile view

Sometimes, you can hide certain elements on your WordPress site when viewed on mobile devices to improve user experience or declutter the screen. CSS media queries make this easy.

Add the following CSS code to your Additional CSS area or child theme stylesheet:

@media only screen and (max-width: 768px) {
.element-to-hide {
display: none !important;
}
}

Replace .element-to-hide with the actual class or ID of the element you want to hide. The code inside the media query will apply only to screens 768px wide or smaller, which typically includes most smartphones and small tablets.

Use your browser’s developer tools to find the correct selector for the element you want to hide on mobile devices.

Add the following CSS code to your Additional CSS area or child theme stylesheet:

21. Hide category metadata from posts

If you want to remove the category information that appears on your WordPress posts, you can do so quickly with custom CSS. This is useful if you prefer a cleaner post layout or want to avoid publicly displaying categories.

Add the following CSS code to the Additional CSS section in your WordPress Customizer or your child theme’s stylesheet:

.post-categories,
.entry-meta .cat-links,
.category-links {
display: none !important;
}

These selectors cover the most common category metadata classes used by WordPress themes. If your theme uses different class names, inspect the category section using browser developer tools and update the selectors accordingly.

Hiding category metadata helps streamline your post appearance and keeps readers focused on the main content.

22. Hide the author information section

Sometimes, you can remove the author information section from your WordPress posts for a cleaner look or privacy reasons.

You can easily do this using custom CSS without touching any theme files. To hide the author info section, add the following CSS code to your site’s Additional CSS area or child theme stylesheet:

.author-info,
.author-box,
.post-author {
display: none !important;
}

This code targets standard author info container classes used by many themes. If your theme uses different class names, inspect the author section with your browser’s developer tools and adjust the selectors accordingly.

By hiding the author section, you keep your posts focused on content and maintain a minimalist design style.

Pro Tips for Using CSS in WordPress

Here are some tips you can use to use CSS in WordPress.

  • Use a Child Theme for Safe Customizations: Always add your custom CSS in a child theme or via the Additional CSS section in the Customizer to avoid losing changes when your theme updates.
  • Leverage Browser Developer Tools: Use browser inspection tools like Chrome DevTools to identify the exact CSS selectors and test your CSS changes live before adding them to your site.
  • Keep CSS Organized and Commented: Write clear comments in your CSS code to explain your changes. This makes it easier to manage and update your custom styles later.
  • Use Specific Selectors to Avoid Conflicts: Be specific with your CSS selectors to prevent overriding unintended elements and maintain control over your design.
  • Test on Multiple Devices and Browsers: Always check how your CSS customizations look on different screen sizes and browsers to ensure a consistent user experience.
  • Minimize Custom CSS When Possible: Keep your CSS code concise and avoid unnecessary styles to improve site performance and loading speed.

Common Mistakes to Avoid

Here are some mistakes you need to avoid while dealing with custom CSS:

  • Editing the parent theme’s style.css directly: Making changes directly in the parent theme’s files can cause customizations to be lost when the theme updates. Always use a child theme or the Additional CSS area.
  • Not using specific selectors: Using broad CSS selectors can unintentionally affect multiple elements, causing design issues. Be as precise as possible with your CSS rules.
  • Ignoring mobile responsiveness: Failing to test or customize your CSS for different screen sizes may result in a poor user experience on smartphones and tablets.
  • Overloading CSS with unnecessary code: Adding excessive or redundant CSS slows your site and makes maintenance harder. Keep your styles clean and efficient.
  • Not testing across browsers: Different browsers can render CSS differently. Always verify your customizations on major browsers to ensure consistent appearance.
  • Forgetting to clear caches after changes: If you use caching plugins, you must clear the cache after adding or editing CSS, or changes may not appear immediately.

Frequently Asked Questions

Now, let’s see some frequently asked questions regarding this topic.

What are the CSS codes to customize WordPress?

CSS codes to customize WordPress are snippets of Cascading Style Sheets used to change the appearance of your website’s elements, like fonts, colors, spacing, and layouts, without modifying the core theme files.

How can I add CSS codes to customize WordPress without affecting the theme?

You can add CSS codes safely using the WordPress Customizer’s Additional CSS panel, a custom CSS plugin, or creating a child theme to ensure your changes aren’t lost during theme updates.

Are CSS codes to customize WordPress compatible with all themes?

Yes, most CSS codes work across themes, but some selectors might vary depending on the theme’s HTML structure. It is best to inspect your theme’s elements and adjust CSS selectors accordingly.

Can I use CSS codes to customize WordPress for mobile devices?

Using media queries within your CSS code allows you to apply specific styles for different screen sizes, ensuring your site looks great on both desktop and mobile.

Do I need to know how to code and use CSS to customize WordPress?

A basic understanding of CSS helps, but you can often copy and paste pre-written CSS codes to customize WordPress. Many tutorials provide easy-to-use snippets for common customizations.

Conclusion

Using CSS codes to customize WordPress gives you the flexibility to design a website that truly stands out.

Instead of being limited by theme settings or bulky plugins, clean, efficient code allows you to tweak fonts, colors, layouts, and more easily.

This improves your site’s appearance and can boost loading speed and overall user experience. By learning to add custom CSS and applying the correct code, you gain complete control over your WordPress site’s look and feel.

Whether you want subtle style changes or a complete design overhaul, CSS codes to customize WordPress are essential for any website owner aiming for a professional and unique online presence.

Do you know any other CSS codes to customize WordPress websites?

Let us know in the comments.

1 comment

Leave your comment

Log into your account
Forgot your password?