Jump to content

Help With Xhtml For Navigation


arcane

Recommended Posts

Let's say that a website has a horizontal navigation bar at the top and that the CSS file styles the navigation bar so that the current page's link has a different colored background than the rest of the navigation bar. Now let's say that none of the CSS works (which is what I often end up pretending when I am trying to code for accessibility). How could I use XHTML to indicate on the navigation bar that the user is on a specific page? I know that not linking that list element is a good clue to the user and I also know that I could use alt text to note that it is the current page. Is there anything else that I could do?

 

Thank you in advance for your input!

Link to comment
Share on other sites

If you use actual &--#60;button&--#62;s or &--#60;input type="image"&--#62;s you can have PHP, Perl, or what-have-you take note of the current page requested and change the button image corresponding to it to a solid color different then the rest. As for the usual &--#60;a&--#62; navbar I think you covered the possibilities, though the biggest clue would be to just leave out the current page in the navbar, which a server-side script could help you do as well, or you could make a different navbar for each page omitting the current page in the list.

Link to comment
Share on other sites

PHP and Perl are server-side languages, they work in any browser. The code I use for my site gets the current page URI, then adds the class .current to the link of the current page. You could then use CSS to style .current however you plan to set it apart.

<ul>
<li><a href="/" <?php if ($_SERVER['REQUEST_URI'] == "/" || $_SERVER['REQUEST_URI'] == "/index.php") echo "class='current'"; ?>>Home</a>
<li><a href="/link" <?php if ($_SERVER['REQUEST_URI'] == "/link") echo "class='current'"; ?>>Link</a>
<li><a href="/link" <?php if ($_SERVER['REQUEST_URI'] == "/link") echo "class='current'"; ?>>Link</a>
<li><a href="/link" <?php if ($_SERVER['REQUEST_URI'] == "/link") echo "class='current'"; ?>>Link</a>
<li><a href="/link" <?php if ($_SERVER['REQUEST_URI'] == "/link") echo "class='current'"; ?>>Link</a>
</ul>

There are certainly more efficient ways to do this, most likely in other languages than PHP. This is just a quick example that works. Replace /link with your URI.

Link to comment
Share on other sites

They're easy to pick up and browsers don't deal with them at all, PHP and Perl are server-side languages, the processing happens on the server and you use variables and objects to create dynamic HTML that varies based on what you want users to see when certain conditions are met.

 

EDIT: Ice ninja'd me :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...