HTML5 By Default

Man Holding a Paper Cutout with the HTML5 Logo

Version 2 of ClassicPress has been out for a couple of weeks now, so perhaps it’s time to start exploring its new features. While much of version 2 adds non-block features forked from WordPress, ClassicPress also now boasts some features of its own.

One of these features is that ClassicPress now outputs HTML5 by default. This is very different from WordPress, which still outputs XHTML by default. But HTML5 has been around since 2008, and became the standard for the web in 2014, so it’s high time we all got with the program. ClassicPress now does that for you.

If you’re coming from WordPress, you’ll know that, in order to output HTML5 on that platform, you need to add something like the following code to your theme:

add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script' ) );

This is no longer necessary in ClassicPress. In fact, having that code in a theme on ClassicPress will cause those with WP_DEBUG set to true to see a Notice telling them that such code is deprecated:

PHP Notice: Function add_theme_support( 'html5' ) was called <strong>incorrectly</strong>. HTML5 is the default

To avoid seeing such a Notice, you can simply remove the now-redundant code from your theme. If, on the other hand, you’re a developer who has created a theme that’s designed to work on both ClassicPress and WordPress, your best option is to wrap the code in a condition that checks whether the site is using ClassicPress, like this:

if ( ! function_exists( 'classicpress_version' ) ) {

    add_theme_support( 'html5', array( 'comment-list', ...

}

Welcome to HTML5!