Index: src/wp-includes/widgets/class-wp-widget-custom-html.php
===================================================================
--- src/wp-includes/widgets/class-wp-widget-custom-html.php	(revision 47433)
+++ src/wp-includes/widgets/class-wp-widget-custom-html.php	(working copy)
@@ -164,16 +164,16 @@
 		$post = $original_post;
 		remove_filter( 'shortcode_atts_gallery', array( $this, '_filter_gallery_shortcode_attrs' ) );
 
-		// Inject the Text widget's container class name alongside this widget's class name for theme styling compatibility.
-		$args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] );
+		$args = apply_filters( 'widget_custom_html_args', $args );
 
+		// Inject the Text widget's container class names alongside this widget's class name for theme styling compatibility.
+		$args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text textwidget custom-html-widget ', $args['before_widget'], 1 );
+
 		echo $args['before_widget'];
 		if ( ! empty( $title ) ) {
 			echo $args['before_title'] . $title . $args['after_title'];
 		}
-		echo '<div class="textwidget custom-html-widget">'; // The textwidget class is for theme styling compatibility.
 		echo $content;
-		echo '</div>';
 		echo $args['after_widget'];
 	}
 
Index: tests/phpunit/tests/widgets/custom-html-widget.php
===================================================================
--- tests/phpunit/tests/widgets/custom-html-widget.php	(revision 47433)
+++ tests/phpunit/tests/widgets/custom-html-widget.php	(working copy)
@@ -112,8 +112,7 @@
 		$this->assertNotEmpty( $this->widget_custom_html_content_args );
 		$this->assertNotEmpty( $this->widget_text_args );
 		$this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output );
-		$this->assertContains( '<section id="custom_html-5" class="widget_text widget widget_custom_html">', $output );
-		$this->assertContains( '<div class="textwidget custom-html-widget">', $output );
+		$this->assertContains( '<section id="custom_html-5" class="widget_text textwidget custom-html-widget widget widget_custom_html">', $output );
 		$this->assertNotContains( '<p>', $output );
 		$this->assertNotContains( '<br>', $output );
 		$this->assertNotContains( '</u>', $output );
