I launched the website some time ago and successfully used Javascript + CSS to highlight the current page in the navigation. However, it does not work in Safari, and it does not validate when using Javascript, so I decided that PHP assigns a CSS identifier to HTML elements. So far, this works just fine, compared to other things when two of each link were shown, when it was taken in PHP. My problem is that all the links look fine and the CSS property is not applied. I have a feeling this is due to my PHP code, but I'm not sure.
Website address here
As for the PHP code, here it is:
<?php
echo('<li><span class="bold">Main</span>');
echo('<ul>');
if ($page=="home")
{
echo('<li><a id="current" href="index.shtml">Home</a></li>');
}
else
{
echo('<li><a href="index.shtml">Home</a></li>');
}
if ($page=="faq")
{
echo('<li><a id="current" href="faq.shtml">FAQ</a></li>');
}
else
{
echo('<li><a href="faq.shtml">FAQ</a></li>');
}
if ($page=="about")
{
echo('<li><a id="current" href="about.shtml">About Bryce</a></li>');
}
else
{
echo('<li><a href="about.shtml">About Bryce</a></li>');
}
echo('<li><a href="contact.php">Contact Bryce</a></li>');
if ($page=="sign guestbook")
{
echo('<li><a id="current" href="sign.shtml">Sign Guestbook</a></li>');
}
else
{
echo('<li><a href="sign.shtml">Sign Guestbook</a></li>');
}
if ($page=="view guestbook")
{
echo('<li><a id="current" href="view.shtml">View Guestbook</a></li>');
}
else
{
echo('<li><a href="view.shtml">View Guestbook</a></li>');
}
echo('</ul>');
echo('</li>');
echo('<li><span class="bold">Info</span>');
echo('<ul>');
if ($page=="projects")
{
echo('<li><a id="current" href="projects.shtml">Projects</a></li>');
}
else
{
echo('<li><a href="projects.shtml">Projects</a></li>');
}
if ($page=="books")
{
echo('<li><a id="current" href="books.shtml">Books</a></li>');
}
else
{
echo('<li><a href="books.shtml">Books</a></li>');
}
echo('</ul>');
echo('</li>');
echo('<li><span class="bold">Misc.</span>');
echo('<ul>');
if ($page=="cover designs")
{
echo('<li><a id="current" href="coverdesigns.shtml">Cover Designs</a></li>');
}
else
{
echo('<li><a href="coverdesigns.shtml">Cover Designs</a></li>');
}
echo('<li><a target="_blank" href="http://www.lulu.com/brycecampbellsbooks">Lulu Store</a></li>');
echo('<li><a href="rss/">RSS</a></li>');
echo('</ul>');
echo('</li>');
?>
, , CSS, :
#current {
font-style: italic;
text-decoration: none;
color: #000000;
}
, , , , , , PHP .