B
B
Borodean2011-09-22 10:47:08
HTML
Borodean, 2011-09-22 10:47:08

Semantics of the current menu item?

I propose to talk about "metaphysics" - the semantics of html-layout.
Let's assume that a site has a navigation block like this:

<nav>
  <li><a href='/cards/'>Карты</a></li>
  <li><a href='/money/'>Деньги</a></li>
  <li><a href='/two-barrels/'>Два ствола</a></li>
</nav>

A visitor clicks on, say, a link about money. There is a transition to the page, and there (according to the rules of good form), the menu item responsible for the current page ceases to be a link.
The question is how to make such a menu item semantically correct?
Yandex offers this option: Habrahabr - this:
<li><b class='active'>Деньги</b></li>
<li><a href='/money/' class='disabled'>Деньги</a></li>

The first option is “bad” because it uses a “dirty” technique in the form of an element b, the second one because it leaves the menu item as a working link.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Anatoly, 2011-09-22
@taliban

The second option is more preferable, and not because the first one is a hack, but because, suddenly, I want to click on the link again? Why clean it up? I just need to show where I am now, but leave all the links in place.

H
habrauser, 2011-09-22
@habrauser

I never thought, I like it when it's like this:

<li><span>Деньги</span></li>

D
dom1n1k, 2011-09-22
@dom1n1k

I do like this:

<li class="active">Главная</li>
<li><a href="/products/">Продукты</a></li>
...

Simple, clear and efficient.
Sometimes another span or div is added inside - if an additional technological wrapper is needed for some visual effects. But this is only if necessary, in the general case without.
On the other hand though... To be honest, I don't see any disaster when an active menu link leads to the same page. Well, it leads - so what? These are purely manic quibbles, in real projects much more "dirty" things are often used.

B
bezumkin, 2011-09-22
@bezumkin

You can change like this:

<li><a href='javascript:void(0)' class='active'>Деньги</a></li>

P
Pavel Myshkin, 2014-03-31
@Pazys

(according to the rules of good manners)
- then, when hovering over this "no longer a link", make a hint, saying [You, sir, are already here]
But something seems to me that this is really from metaphysics and indispensable to reality (except for the active XK page) ... although if many people do this, then users will get used to it.

I
Ilya Plotnikov, 2011-09-22
@ilyaplot

Remove the tag, it's better to assign class active to the element, and write li.active {} in css.
I don't think onclick in the link is appropriate, because I can follow the link using the keyboard.
Maybe even href="#"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question