Title: WP_Widget_Recent_Comments::recent_comments_style
Published: April 25, 2014
Last modified: February 24, 2026

---

# WP_Widget_Recent_Comments::recent_comments_style()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#wp--skip-link--target)

Outputs the default styles for the Recent Comments widget.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#source)󠁿

    ```php
    public function recent_comments_style() {
    	/**
    	 * Filters the Recent Comments default widget styles.
    	 *
    	 * @since 3.1.0
    	 *
    	 * @param bool   $active  Whether the widget is active. Default true.
    	 * @param string $id_base The widget ID.
    	 */
    	if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876.
    		|| ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) {
    		return;
    	}

    	$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';

    	printf(
    		'<style%s>.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>',
    		$type_attr
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets/class-wp-widget-recent-comments.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets/class-wp-widget-recent-comments.php#L44)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets/class-wp-widget-recent-comments.php#L44-L64)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#hooks)󠁿

 [apply_filters( ‘show_recent_comments_widget_style’, bool $active, string $id_base )](https://developer.wordpress.org/reference/hooks/show_recent_comments_widget_style/)

Filters the Recent Comments default widget styles.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#related)󠁿

| Uses | Description | 
| [current_theme_supports()](https://developer.wordpress.org/reference/functions/current_theme_supports/)`wp-includes/theme.php` |

Checks a theme’s support for a given feature.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_widget_recent_comments/recent_comments_style/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_widget_recent_comments%2Frecent_comments_style%2F)
before being able to contribute a note or feedback.