
How to hide parts of your WordPress site with CSS (Beginner-Friendly Guide)
In WordPress, you may come across sections on your site that you’d prefer not to display — such as unnecessary forms, theme banners, comment boxes, and so on. When the theme or plugin doesn’t offer a setting to disable these sections, a very practical solution is to hide them using CSS.
This method is quick, reversible, and doesn’t require advanced coding skills. In this beginner-friendly guide, you’ll learn:
- How to identify the element you want to hide using Chrome’s developer tools.
- How to write the correct CSS code.
- Where to place that CSS in your WordPress site.
Step 1: Identify the Element’s Class or ID
First, you need to find the name of the element you want to hide. We’ll use Google Chrome’s developer tools for this:
- Open your site in Chrome.
- Right-click on the element you want to hide and select “Inspect”.
- A split view will appear showing the HTML code. As you move your cursor over elements in the inspector, you’ll see corresponding parts of the page highlight.
- Identify whether the element has an ID (
id="something"
) or a class (class="something"
).
Which is better: ID or class?
- ID (
#something
): It’s unique on the page. This is the most precise and reliable method because the ID won’t be repeated elsewhere. - Class (
.something
): It can be shared by multiple elements. Use this carefully — you might end up hiding more content than intended.
<div id="promo-banner" class="ad highlight">
In this case, using #promo-banner
is safer than .ad
, since the ID is unique.
Step 2: Write the CSS code
Now that you know the selector (ID or class), you can write the CSS rule to hide the element.
#promo-banner { display: none; }
Or using a class:
.ad { display: none; }
If the style isn’t applying correctly, you can force it with !important
:
.ad { display: none !important; }
Alternative:
There’s another CSS property called visibility: hidden
, but it’s not recommended for this purpose. While it hides the content visually, it still occupies space on the page.
#promo-banner { visibility: hidden; }
This can leave gaps or affect the site layout. That’s why display: none
is usually the better option.
Step 3: Where to place the CSS?
You have several options for adding this CSS to your WordPress site, depending on your experience level. Here are the most common ones:
Option A: use the WordPress customizer
Perfect if you want a quick solution without installing anything extra.
- Go to Appearance > Customize.
- Open the Additional CSS section.
- Paste your code.
- Click Publish.
Option B: use a Snippet plugin
If you prefer to keep your customizations organized without editing theme files, you can use a plugin like WPCode.
- Install WPCode – Insert Headers and Footers + Custom Code Snippets.
- In the WordPress dashboard, go to Code Snippets > Add New.
- Choose the CSS code type.
- Paste your code and activate the snippet.
Option C: add it to the style.css
file of your child theme
If you’re using a child theme, you can add the CSS directly to its style.css
file.
- Go to Appearance > Theme File Editor.
- Select the child theme’s
style.css
. - Paste your CSS code at the bottom and save.
Option D: use a mu-plugin with wp_head
.
If you want a more technical and reusable solution, you can create a mu-plugin (must-use plugin) to insert your CSS via PHP using the wp_head
hook.
- Create the folder
wp-content/mu-plugins/
if it doesn’t exist. - Inside it, create a file called
custom-css.php
. - Paste the following content:
-
<?php add_action( 'wp_head', function () { echo '<style> #promo-banner { display: none !important; } </style>'; } );
-
- Save the file. WordPress will load it automatically.
Hiding sections with CSS is a great way to gain visual control over your site without diving deep into code. All you need is:
- To identify the element’s ID or class.
- Write a simple
display: none
. - Add it in the right place inside WordPress.
This simple trick can help you solve many common layout issues — no developer required.