Add a unique ID to to the body element with PHP


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. <body id="<?= basename($_SERVER['PHP_SELF'], ".php")?>">

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.