How to edit ALT tag on your site logo

Last updated on
26 September 2016

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

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" />

Help improve this page

Page status: No known problems

You can: