WordPress functions wp_list_categories() and the_category() render the list of categories and the related post categories respectively in a WordPress theme. These functions also add some extra information with the rendered categories’ HTML, for instance, observe the below segment of code which was generated when I used wp_list_categories() function in my theme, the highlighted sections are that extra information:

<li class="cat-item cat-item-1330"><a href="http://techably.com/resources/" title="View all posts filed under Resources" rel="category tag">Resources</a>

WordPress provides a pattern of styling and occurrence of categories, that’s why it’s functions wp_list_categories() and the_category() add extra classes (class="cat-item cat-item-xxx") and relationship (rel="category tag") attributes with the category HTML.

If you check your WordPress site for HTML5 validation, you may get warnings and errors due to one of these extra pieces of code: rel="category tag", added automatically by the category functions of WordPress. The below screenshot shows the errors produced by these relationship attributes while HTML5 validation:

remove rel category tag

Can I remove rel=”category tag” from WordPress categories?

Well, the answer is Yes. All you need to do is copy the below given code and paste it in your functions.php before the closing PHP tag i.e. ?>:

function snip_category_rel($result) {
    $result = str_replace('rel="category tag"', '', $result);
    return $result;
add_filter('the_category', 'snip_category_rel');
add_filter('wp_list_categories', 'snip_category_rel');

The above code makes use of str_replace PHP function, which helps replacing a particular string of characters with a desired one. We’ve created a function prototype with a parameter $result which collects the replacement of the string rel="category tag" with a blank character ('') and then we hooked that function to wp_list_categories() and the_category().

Now, check your site for HTML5 validation and it won’t show any errors due torel="category tag".