How to have the same div tag on multiple web pages?

Answer this question

  • How to have the same div tag on multiple web pages?


Answer #1 | 24/12 2013 13:07
I just want to say that the first method Chris provided is your best bet for maintaining your code for re-usability. @mnmboy Sorry but Server side code is the best way to maintain or manage your html code. No decent website uses plain HTML and CSS anymore. Plus the performance hit is so small you wouldn't even notice it. There is a balance between site performance and man hours for maintenance and not using a server side language for performance is just not a good enough argument. I guess I should answer this question since I have written this much. Lets say you want to have a navigation menu at the top of every page. If you had to add a link to the menu you would have to change every single HTML file. In PHP you would have to just change one file (lets call it navigation.php) and reference that file in every page. This makes things extremely easy for someone to maintain a site, especially if it has tons of pages. Here is a quick code example of what I am talking about: navigation.php
  • link 1
  • link2
  • ...more links
==================================== page.php
some content
======================================= So for every page you create you just add that one line of php to every page to display the navigation html. When you need to add a link to the menu just edit the navigation.php file and all pages referencing it will show the updated menu. Easy as pie. Server side coding can be a bit of a process when first diving into it so here is an introductory tutorial for you to go by if you need to learn it.

Possible answer