Custom Frontend CSS

Add custom CSS to your website’s frontend without editing theme files. Your styles are stored in the database, so they survive theme updates and don’t require a child theme for simple customizations.

Use Cases

  • Make quick design tweaks without creating a child theme
  • Override plugin CSS that doesn’t match your site’s design
  • Fix mobile layout issues with responsive CSS
  • Customize colors, fonts, and spacing across your site
  • Hide elements or adjust layouts without editing PHP

How It Works

  1. Enable the module in Switchboard
  2. Enter your custom CSS in the code editor
  3. Save your changes
  4. CSS is automatically added to every frontend page

Where to Find It

Location: Your custom CSS is applied to all frontend pages. Configure it in the module settings.

Writing Custom CSS

Enter your CSS exactly as you would in a stylesheet:

/* Change the site's primary color */
.site-title a {
    color: #4f46e5;
}

/* Increase paragraph spacing */
.entry-content p {
    margin-bottom: 1.5em;
    line-height: 1.8;
}

/* Hide the sidebar on mobile */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
}

Common CSS Examples

Typography

/* Custom font for headings */
h1, h2, h3, h4 {
    font-family: 'Georgia', serif;
}

/* Larger body text */
body {
    font-size: 18px;
    line-height: 1.7;
}

Colors

/* Change link colors */
a {
    color: #4f46e5;
}

a:hover {
    color: #4338ca;
}

/* Button styling */
.wp-block-button__link {
    background-color: #10b981;
    border-radius: 8px;
}

Layout Adjustments

/* Wider content area */
.entry-content {
    max-width: 800px;
}

/* Add padding to containers */
.site-content {
    padding: 40px 20px;
}

Hide Elements

/* Hide post meta */
.entry-meta {
    display: none;
}

/* Hide specific widget */
.widget_recent_comments {
    display: none;
}

Mobile Responsive

/* Stack columns on mobile */
@media (max-width: 768px) {
    .wp-block-columns {
        flex-direction: column;
    }

    .wp-block-column {
        width: 100% !important;
    }
}

Finding CSS Selectors

To style a specific element, you need its CSS selector. Here’s how to find it:

Using Browser Developer Tools

  1. Right-click on the element you want to style
  2. Select “Inspect” or “Inspect Element”
  3. Look at the highlighted HTML for class names
  4. Use those classes in your CSS

Common WordPress Classes

ElementTypical Class
Post title.entry-title, .post-title
Post content.entry-content, .post-content
Sidebar.sidebar, .widget-area
Header.site-header, #masthead
Footer.site-footer, #colophon
Navigation.main-navigation, .nav-menu
Comments.comments-area, #comments

Using !important

Sometimes theme or plugin CSS has high specificity. Use !important to override:

.element {
    color: red !important;
}

Use !important sparingly — it’s a last resort when normal specificity doesn’t work.

CSS Validation

Your CSS is automatically sanitized for security:

  • Script tags are removed
  • JavaScript URLs are blocked
  • Malicious properties are filtered

Standard CSS always works correctly.

FAQ

Will my CSS survive theme updates?Yes! Your CSS is stored in the WordPress database, not in theme files. Theme updates won’t affect it.
Should I use this instead of a child theme?For simple CSS changes, this module is faster and easier. For extensive customizations or PHP changes, a child theme is still better.
Does this work with page builders?Yes, your CSS applies to all frontend pages, including those built with Elementor, Beaver Builder, etc.
Can I use CSS variables?Yes, modern CSS features like variables, flexbox, grid, and media queries all work.
How do I target a specific page?WordPress adds body classes for each page. Use selectors like .page-id-42 or .single-post to target specific pages.
What if my CSS isn’t working?Check specificity — the theme’s CSS might be more specific. Try adding !important or using more specific selectors. Also check browser cache.

Use your browser’s developer tools to test CSS changes live before adding them here. This saves time and ensures your styles work correctly.

This module adds CSS to the frontend only. For admin area styling, use the Custom Admin CSS module instead.

PRO

Get access to all 147 modules with a single license

Upgrade to Pro