You probably don’t need this anymore, but in case anyone else comes across this thread w/ the same problem.
For a page with a post_name (slug) of “about-me”:
<?php
$pageName = is_page('about-me');
?>
<body id="<?php echo $pageName ?>">
check out http://codex.ww.wp.xz.cn/Conditional_Tags
For situation’s like pepelsbey’s, where the number of posts on the page might be less than $posts_per_page, you can check against the length of the $posts array rather than $posts_per_page:
<?php
$postCount = 0;
// Start of The Loop
if (++$postCount == 1) {
// FIRST POST
}
if ($postCount == sizeof($posts)) {
// LAST POST IN LOOP
}
// End of The Loop
?>