Makerere University

Enter a keyword or two into the search box above and click search..

Add a placeholder text to search box – Drupal 7

You are here

HTML5 introduce new attribute for textbox ‘placeholder’ which is very useful for display text inside textbox.

You can use following code in your template.php file:


// Add some cool text to the search block form
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    // HTML5 placeholder attribute
    $form['search_block_form']['#attributes']['placeholder'] = t('Search...');