Add custom class to a tags [closed]

As s_ha_dum said, Widgets are not meant to be used like this.

If you want to change the behavior of all your h3 tags inside your posts, WordPress has already article with “post” or “type-post” classes so you should modify your css like this :

.post h3 {
***
}

If you want your change to affect only a specific type of posts :

  1. Add a specific class mySpecificPostClass around the posts you want to change
  2. Modify your css style and use something like

.mySpecificPostClass h3 {
***
}

More detail here.

Edit 1 :

if you want a plugin to do it, you will find a first answer here: Where is the right place to register/enqueue scripts & styles.

For a tutorial on plugin creation, look here: https://codex.wordpress.org/Writing_a_Plugin

In the case of a plugin, as you want to change to behavior of the h3 tags of posts, you don’t have to add specific class :

  1. Create a style to overload the default style only for h3 tags inside “post” class :
    .post h3 {
    *your style*
    }

  2. Add your style in the queue with a plugin

Then your new style will be added to the default style without any change in the theme.

You will want to use a specific class only if you are gonna use it someplace else. If you want to use it only for all posts as your question suggest, no need for that.

Edit 2 :

You can overload the function post_class() ( http://codex.wordpress.org/Function_Reference/post_class) using a filter : add_filter('post_class','my_func')

Your function my_func will then have to return the regular classes plus your specific one.