treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Use PHP to add a unique body ID

  • <?php $page = basename($_SERVER['PHP_SELF'], \".php\");?>
    <body id=\"<?php echo $page ?>\">



    i discovered this useful piece of code while updating my homepage. It takes the filename, removes the ".php" from the end, then applies that as a body id. Its extremely useful when you need page specific css, such as body#contact p{font-size:2em}.

    Hope this helps
  • what a great idea :) thanks for sharing :)