1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

DEALING WITH EMPTY TAGS IN WORDPRESS

If you are dealing with empty tags in WordPress you have come to the right place. I have a very simple solution for you to carry out. Thanks to CSS3 we have a selector that will look for anything that is empty in your website and put a “display:none” commend to those empty tags.

Dealing With Empty Tags In WordPress that are Paragraphs *

WordPress by default creates a paragraph tag on everything. So as soon as you start writing your post or page WordPress will dynamically add

<p>

to everything with a closing

</p>

tag. However if you have ever been in your editor in your dashboard and writing you will sometimes hit the return or enter button a couple of times to give it some space. This is not the way to handle new paragraphs or spacing in WordPress. The real problem comes in when you try to go to text view and see the extra “p” tags but you cannot see them because WordPress hides the “p” tags.

Subscribe To My YouTube Channel:

Empty “p” Tags *

You could have several empty “p” tags that you are not aware of. If you have blogged for quite sometime you more than likely have thousands of empty p tags that you are not aware of. I know that I have had several empty “p” tags in our WordPress here at a1websitepro but we were able to remedy that problem with the solution below.

How to deal with Empty “p” tags In WordPress *

  1. Install a custom CSS plugin OR,
  2. Edit your child theme style sheet.
    1. Go to Appearance
    2. Themes
    3. Edit Stylesheet
  3. Then you want to put this code in the bottom of the style sheet.
p:empty {
    display: none;
    }

Dealing With All Empty Tags in WordPress *

So this method does good when you want to take care of all the empty paragraph tags but what about other empty tags? There are image tags, heading tags and more. There is a solution for this as well in CSS. If you want to make sure that there are NO empty tags in your WordPress CMS us the code below. This will get rid of all empty tags on your website. You can use this code in any website or any CMS to deal with the empty tags.

Drawback to using this code for all Empty Tags *

One of the drawbacks for using this code for all empty tags is the fact that form items with empty elements will not be shown. So if you have a contact form with an input type that has no value this code will remove it altogether.

*:empty {
    display: none;
    }

SEO AND DEALING WITH EMPTY TAGS IN WORDPRESS *

Will empty tags affect the SEO on your website? Probably because of the fact that search engine spiders often look for proper punctuation, heading tags and more to decide the worthiness of your website. If you have a bunch of empty tags lying around you will probably suffer the consequences of having them there. Use the real estate on your website wisely. Sometimes space is good but you should handle it with the style sheet and not empty “p” tags.

DEALING WITH EMPTY TAGS IN WORDPRESS was last modified: June 3rd, 2015 by Maximus Mccullough

Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips

Tips

DEALING WITH EMPTY TAGS IN WORDPRESS-1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.