Warning message

Documentation is currently being migrated into the new system. Some pages might be temporarily missing, and some guides might appear empty. Thank you for your patience while we are improving Drupal.org documentation.

How to edit ALT tag on your site logo

Last updated on
September 26, 2016 - 08:08

By default, users don't have control over the Alt text that gets used with their site logo. To write a custom Alt text for your logo, you need to do the following:

 

  1. Start with a copy of your theme's page.tpl.php file to edit
  2. Locate the code that is rendering your logo. It will look something like the following:
    
    
    <?php if ($logo): ?> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"> <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /> </a> <?php endif; ?>
  3. Locate the img tag, followed by the print $logo text. Here's your logo image. Following that is the alt tag, which currently has the value of "Home".<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
  4. You can remove the current snippet and add you own ALT tag, such as: <img src="<?php print $logo; ?>" alt="My Site Logo" />
  5. You can also keep the existing snippet and add your own text afterwards, such as: <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?> and my custom alt text" />