Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 47435)
+++ src/wp-includes/media.php	(working copy)
@@ -1786,33 +1786,33 @@
 	$style = '';
 
 	if ( $caption_width ) {
-		$style = 'style="width: ' . (int) $caption_width . 'px" ';
+		$style = 'style="max-width: ' . (int) $caption_width . 'px" ';
 	}
 
 	if ( $html5 ) {
 		$html = sprintf(
-			'<figure %s%s%sclass="%s">%s%s</figure>',
+			'<figure %s%sclass="%s">%s%s</figure>',
 			$id,
 			$describedby,
-			$style,
 			esc_attr( $class ),
 			do_shortcode( $content ),
 			sprintf(
-				'<figcaption %sclass="wp-caption-text">%s</figcaption>',
+				'<figcaption %s%sclass="wp-caption-text">%s</figcaption>',
 				$caption_id,
+				$style,
 				$atts['caption']
 			)
 		);
 	} else {
 		$html = sprintf(
-			'<div %s%sclass="%s">%s%s</div>',
+			'<div %sclass="%s">%s%s</div>',
 			$id,
-			$style,
 			esc_attr( $class ),
 			str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),
 			sprintf(
-				'<p %sclass="wp-caption-text">%s</p>',
+				'<p %s%sclass="wp-caption-text">%s</p>',
 				$caption_id,
+				$style,
 				$atts['caption']
 			)
 		);
