Posted By

danielwrobert on 01/05/11


Tagged

php body-id


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

scilec


Add a unique ID to to the body element with PHP


 / Published in: PHP
 

URL: http://css-tricks.com/id-your-body-for-greater-css-control-and-specificity/

From an awesome comment on how you can use PHP to apply the unique ID to to the body element. This will return the name of the PHP file being executed as the ID (e.g. body id="index.php"). To leave off the .php part, just remove the ".php" part.

  1. <body id="<?= basename($_SERVER['PHP_SELF'], ".php")?>">

Report this snippet  

You need to login to post a comment.