Joomla Tips: How to assign body IDs to each page

Here is the code I use to add an individual ID to each page in a Joomla website. In index.php of your site’s template folder, add this code in place of the < body> tag:

$menu = &JSite::getMenu();
$active = $menu->getActive();
<body id="<?php print $active->alias; ?>">

Now, each page will have it’s own ID. For example, will have the ID “about-us.”