CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
Other Discussions
Use PHP to add a unique body ID
chazzwick
Permalink to comment
#
March 2009
<?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
Robskiwarrior
Permalink to comment
#
March 2009
what a great idea :) thanks for sharing :)
Add a Comment
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