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:
- Start with a copy of your theme's page.tpl.php file to edit
- 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; ?> - 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'); ?>" /> - You can remove the current snippet and add you own ALT tag, such as:
<img src="<?php print $logo; ?>" alt="My Site Logo" /> - 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:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion