0

I made websites years ago with html and frames. Now I could see all modern pages are using html5 with css (div). I already know how to make a nice website DESIGN, but I am struggling with the navigation on a website.

Lets say I have a website index.html with 2 divs (div navigation and div content).

When I click on a link in the menu bar (div navigation) the href is another .html file. Fore example I have a link to about.html.

Is the about.html a copy of index.html, just with another text in the div content? So the menu is build again?

This would mean for every side I have to copy the index.html and re-write the div content part. And the div navigation part will always be the same?

I am really struggling with the idea to have the menu bar on every single file every time again, instead the old frame-style, if this is how it is used.

jeekay
  • 109
  • 1
  • 1
  • 3
  • 1
    Most current websites are not “static” any more, but use some sort of (server-side) technology that allows to include the same menu structure into the different pages of the site. – CBroe Aug 23 '15 at 14:22

1 Answers1

0
  1. You can store you navigation in a single file like my_awesome_menu.php and use include 'my_awesome_menu.php'; in every page of your website. When you add new items in my_awesome_menu.php the changes will take place at all your pages. It will work only if you have server running. It won't work on your desktop like it was with html files, because there will be nobody to execute php files.
  2. You should store all styles in an external .css file or files. It's easy to maintain and you can get significant benefit because browser will cache styles once it would be downloaded. It means when user will open second page he won't load CSS again, he will load only HTML of this particular page.
Cheslab
  • 1,896
  • 2
  • 17
  • 27
  • @1: Yes I did already try functions in php. But in the function you have to use 'echo "html code"' for any html code if I am not wrong. And i read this is a very bad solution. @2: Yes this is how I already know it. But so I have to build the menu on every single site (.html file) again? So the whole website is build up again every time I click on a link? This means I have some parts of code in every single .html file. When I change the menu, I have to change it in every single .html file?! – jeekay Aug 23 '15 at 14:54
  • @jeekay you don't have to use any php in `my_awesome_menu.php` it also can be `my_awesome_menu.html`. You just include whole content of this file to any place of another file where you insert php `include` function. The `echo` function is used when you write php code. The only php code in your case are limited by phrase `` – Cheslab Aug 23 '15 at 15:07
  • Nice thx, just tried it. It works great :-) – jeekay Aug 23 '15 at 15:20