I am trying to understand how add_theme_support() function works, but at the section of Html5 i tried to use it with gallery and i noticed that the markup has changed for it,and here is what i did

add_theme_support( 'html5', array('gallery') );

but for the others like search-form or comment-form for example

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

i didn't notice any change in the output, so Am i missing some thing? or how it works?

2 Answers 2


According to the documentation, you must pass an array of items where you want to enable HTML5 markup:

add_theme_support( 'html5', array(
    // Any or all of these.
) );

The documentation also recommends using add_theme_support() on the after_setup_theme hook, stating that the init hook may be too late for some features.


Developer documentation: add_theme_support() » HTML5

  • sorry there is a miss understanding, i will edit my question Sep 6, 2017 at 14:24
  • 1
    Since WordPress 5.3 add_theme_support allow more parameters: style and script, to respectively remove type="text/css" and type="text/javascript" from links in enqueued scripts and styles. For example:add_theme_support('html5', ['script', 'style']); Jan 13, 2021 at 16:15

I have figured out why no changes happens, and the problem was that i am calling a custom search form file searchform.php and the function add_theme_support() affects the built in features only. So if you want to use the default search form by calling get_search_form() without having the searchform.php file, then you can use

add_theme_support( 'html5', array( 'search-form' ) );

and this will apply an html5 markup to the form. The following are the before and after add_theme_support()(Contains Arabic Text):


<form role="search" method="get" id="searchform" class="searchform" action="http://localhost/TB/">
                <label class="screen-reader-text" for="s">البحث عن:</label>
                <input value="" name="s" id="s" type="text">
                <input id="searchsubmit" value="بحث" type="submit">


<form role="search" method="get" class="search-form" action="http://localhost/TB/">
                <span class="screen-reader-text">البحث عن:</span>
                <input class="search-field" placeholder="بحث …" value="" name="s" type="search">
            <input class="search-submit" value="بحث" type="submit">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.