I have a website in which i use tabs to navigate between pages. For example, page a displays A as an active tab and B and C background tabs. If the visitor gets to the website via page B, i also would like to display to page d, but not a and c.

Question: I know i can just create index2 for b for example, so when the visitor gets to b from a, i display a,b,c and index1 when visitor gets to b from d for example. Is that a bad practice? I know double content isn't good, but in which other way can i or should i approach this problem?

The tab navigation i designed uses < li > and id tag do display active tab, defined in the < body > tag.

2 Answers 2


You should probably be using url fragments to determine which tab gets shown. This will mean you only have a single page to work with.

A url fragment is the bit after a # symbol. For instance;

http://mysite.com/index.html#a http://mysite.com/index.html#b http://mysite.com/index.html#c

You could even use more descriptive fragment names if you wished.

Once you have these fragments in the URL you can use javascript (or jQuery) to show/hide the tabs.

The way I would construct this would be to "stack" the different tabs so they are all visible (one below the other). Then, when the page loads, use javascript to form them into the tabs and show/hide the relevant tab based on the url fragment.

The benefit is that if the visitor doesn't use javascript they will still be able to navigate the site and the page will 'jump' to the correct section automatically because of the fragment.

  • Although i must say, i never thought of using fragments in such way, only to specific sections of a page. Very interesting. Oct 26, 2012 at 11:44

Each url should identify clearly a content, so depending on how much you care about usability, accessibility and related practices, you will choose one or other option.

Separated pages is the best option for many reasons, but is understandably that you want to use one and just hide content. If you choose to use one, you have easy control, as you mentioned, about the links, plus using cacheable images, the traffic is not going to be big.

If you choose to have one page, your best bet is to process the request with a server language and remove the content you don't want to show or just add what you want to show.

  • If removing or changing the content from the page server side you need to be extremely careful as this will effectively mean that different pages will be served under the same URL. A search engine won't properly index your content as everytime it hits the page the content will be different. Keeping everything on the page and showing/hiding based on a url fragment is not without potential issues but is, in my opinion far 'safer' than changing what is served to the browser.
    – foamcow
    Oct 25, 2012 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.