Add Theme Support for HTML 5 Figures and Figcaptions to WordPress Images
Finally, WP has caught up to HTML5 when inserting images and galleries. Previously, images with captions were contained in
<div> tags with the caption in a normal
Now you can get them all modern and semantic and awesome and stuff.
Just add this to your theme’s function.php file:
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ))
array bit there handles which types of elements should get HTML5. So if you’re just looking for galleries, and captions, delete the other items. Like this:
add_theme_support( 'html5', array( 'gallery', 'caption' ))
Note that if you’re not developing a theme, just modifying something existing, you’ll need to do some CSS updating, too. This article, and the comments section, won’t cover how to do that as every theme is different.