tags:

views:

72

answers:

3

Hi All,

I am a rookie CSS user, i have the following nav menu code and CSS to go along with it. The funny thing is that when i hover over the <p> element (You are viewing page xxx) in the nav menu, it changes colors as if it was an anchor tag, specifically hover.

I am very confused why it does this, I tried to be as specific as possible when selecting the anchor tags but it made no difference, I'm guessing it has something to do with inheritance but I'm not 100% sure. Can anyone explain to me why this is happening? Thanks

<?php 
// Generate the navigation menu
echo '<div id="navmenu">';
echo '  <p>';
echo '      <h3><a href="index.php">Compliance Report<a/> - <a href="nonreportinghubs.php">Non-Reporting Hubs<a/> - <a href="FastReportingHubs.php">Fast Reporting Hubs<a/> - ';
echo '      <a href="inactivehubs.php">Inactive Hubs<a/> - <a href="inactivebutreporting.php">Inactive But Reporting Hubs<a/><br />';
echo '      <a href="logins.php">Logins<a/> - <a href="customerlogins.php">Customer Logins<a/>  - <a href="checklogins.php">Check Logins<a/> - <a href="dbsize.php">Database Size<a/></h3>';
echo '  </p>';
echo '  <p> You are viewing <span class="page_title">' . $page_title . '</span></p>';
echo '</div>';
?>
#navmenu {
border:                         2px solid gray;
text-align:                     center; 
}

#navmenu a:link {
color:                          black;
}

#navmenu a:visited {
color:                          black;
}

#navmenu a:hover {
color:                          gray;
}
+5  A: 

You close tags like: </a> not <a/>. <a/> will generate a new empty <a> and since you never close any of your <a>'s your whole <p> is basically the the <a> that is nested inside.

shoebox639
Almost certainly -- you should run your HTML through the W3C Validator to see what errors you have. http://validator.w3.org/
Spudley
EDIT: to be less snarky :)
shoebox639
Also invalid <h3> inside <p> tag (not that this is causing the error), pick-one stick with it
BenWells
I dont know how I missed that, i guess starring at something for a while i skip over the easy stuff. good catch.
Drewdin
@spudley I usually do, but since I have it broken out into separate PHP pages I cant validate the HTML on that page. Is there a PHP validation page? I didnt think there was one since it can be whatever you want it to be, thanks.
Drewdin
That was it, thanks for the help, i appreciate it. again, I am a rookie but that was a bad mistake on my part, I dont know how I missed that.
Drewdin
@Drewdin - validate the generated HTML, not the PHP code. open the page in the browser; view source; copy+paste entire source into w3c validator.
Spudley
thanks, i didnt even think of that!
Drewdin
A: 

Your HTML is invalid.

You cannot have an <h3> element inside a <p> element. When you start the <h3> you end the paragraph (implicitly as end tags are optional for <p>). The browser then sees </p> as an error and silently discards it.

Get rid of the <h3>, whatever that data is, it isn't a sub-sub-heading anyway.

<a/> is nonsense as well. You probably mean </a>.

It looks like you would do well to learn to use http://validator.w3.org/ — it does a very quick and easy first pass QA for markup.

David Dorward
Thanks, i'm going to remove the h3's now.
Drewdin
A: 

You are ending your anchor tags with <a/> instead of </a>

Christopher W. Allen-Poole