simple static html menu - html

I'm new at HTML and need to do a simple site as an assignment. For the site navigation menu I guess it would be easy to simply copy and paste the navigation menu HTML onto all the pages in a header div. But is there a better way to do this?
for example, is there an easy way (that doesn't require scripting) to only write the code in one place and have it included on every page? I remember that I did something in Dreamweaver that created a template page that included the navigation menu. However I have a feeling that that was just copying html between pages.

Without scripting your HTML files will need to contain the menubar in full.
You are describing what a server side scripting language can do. Without one - your HTML files are served as they are. Therefore they must contain the HTML for the menubar within them.
The comments mention using an iframe - though very creative - I believe it doesn't satisfy as being "a better way to do this"

You have must use HTML code every page without HTML does't work Try to learn some basic PHP it will help

Related

One navigation bar for multiple pages without JavaScript

I have found many solutions for this question through JavaScript, but I want to be able to have a website that does not require JavaScript so as to be friendly with non-JS web browsers. I am trying to have a navigation bar on multiple websites without needing to change every HTML page whenever I want to make an update. How can I achieve this? Could I load an HTML file without JS?
If you do not want to use javascript, the other option would be to use PHP to include the files on all the pages you would require the navbar. So essentially, you would copy the navbar snippet into a single file, then using PHP methods (require or include), to add the snippets on all other pages. This way, you only need to edit that navbar snippet you copied whenever you need to make a change and it'll take effect on any page you have either required or included. More info on how to use include and require here

Create navigation Bar From Different HTML, Link to Main HTML

i just wanted to find out is it posible to make a navigation bar or image slide from a different html & css and link it to the main index.html?
if it is possible how to do it, or must it be done as a script?
It's possible to do this with both Javascript/jQuery and PHP. It's also possible to do this with an iframe, but iframes are honestly used to load a new web page within your site and they are hardly ever used, plus HTML5 is going to depreciate them once it becomes standard. So to answer your question, yes, it's something that needs to be done with a scripting language

accessing menu from several subcategories

Is there any other way to access one and the same menu without re-adding the code for it in each "page"?
I mean a menu looks exactly the same, no matter which part of the site you´re in.
So there should be a way to have that menu attached to every page on the site without adding the code for every page you create?
Which language you want to use for your site development?
There are lot of frameworks available for each language.
For example struts with tiles in java.
In tiles concept you will be defining some base layouts. which will specify header here sidebar here etc.
Then on next pages you can simply extend your new page into your base layout. There even if you are not specifying any content specifically, it will take previously defined one by default.
For example refer the struts tiles example link.
In jsp there is an option to add a page within an another page. Key word is
<%# include file='menu.jsp'%>
here menu.jsp is mu menu bar, which I am calling to a location in my page. So hat it it will appear in the place where I specified. If you are not comfortable with tiles concept, you can use this method for adding menu into your pages with out repeating entire codes in all pages.
There are a good number of ways to do this, and as far as I am concerned, they all use PHP or something similar to generate the HTML menu code on each individual page.
The browser must have all the content or it will not display a particular part. One can either hard code something like a menu into every html page or they could create something more of a php site which generates the html and serves it to the browser.
Other the writing the php yourself, off the shelf solutions will (often) allow you to do this. Examples would be shopping carts, as well as content management systems (CMS).

Is it possible to create a web site header without copying and pasting it on every page?

I'm building a small-scale website (a personal one) in which each page would have the same set of header elements (I'm not talking about the <head> element). In other words, I want each page to have essentially the same title at the top of the page and the same navigation bar below that (with possibly minor differences in each page). It's kind of like how StackOverflow has that navigation bar (with the logo, and the Questions, Tags, etc. buttons) on the top of every page.
Is it possible create such a header for every web page without copying and pasting the HTML code to do so? I really don't want to run into a situation where if I want to make a single change, I would have to change all of my pages containing the header.
Real web sites use real web frameworks, which have a concept called a "layout" (at least that's what they're called in Rails; as mentioned in Uwe's answer, they're called master pages in ASP.NET). All the common "templatey" stuff goes into a layout.
How about include files in a server-side language like PHP or master pages in ASP.NET?
You need to use some kind of dynamic page processing, whether it's PHP, a server-side include, or a similar tool.
If you need to stick with straight HTML, you could try to rig something up with AJAX or JavaScript - but then you highly limiting your website's functionality, giving it serious performance issues, AND preventing users who have JavaScript disabled from using your website.
A third answer is to use some sort of pre-deployment tool. This used to be a bigger market, but I think it's mostly dried up now. Here's an example for using DreamWeaver to handle this.
If you have a PHP server that supports PHP,
<?php include 'header_inc.php'; ?>
If that's not available
<!--#include virtual="header_inc.html" -->
But whether this works or not is server dependent
If you have a server with PHP capabilities
include 'header.inc.php';
you must put the header code in a file named that and then put that include code in all pages that you want the header to show up on

Embeding a secondary HTML file within a webpage

I still don't feel comfortable repeating HTML for things like menu code, header, footer and most importantly a quick links/news panel on each page. Also it seems a little inefficient to keep sending the same repeated html for each page.
For the moment I have written a small program which reads these sections from my index.htm and replaces the relevant sections within all other pages in that directory. However things have started to get considerably more awkward now that I have extra pages like a Message Forum and Image Gallery, both of which require their own index.htm in their respective sub directories.
So the question is should I be using object, iframe or SSI?
Has anyone successfully used the object tag to embed a separate HTML file within a page? SSI would do the job except that the repeated HTML is still being sent across the web on every page change and different include lines would have to be used on the PHP pages. What about using IFrames, I know they are not strict XHTML1.0 compliant but I seem to recall rumors that they are going to br supported in HTML5 again, does that make them a good bet for the future?
The easiest way to solve this problem is by using a scripting language (PHP, Python, ASP) and templates. You can create the basic structure for your site in a master template, then use the scripts to pull in only the content that changes.
For a particularly good example, see Django's template system.
Each of your pages could call a JavaScript function in an external boilerplate.js file. That function could add boilerplate elements to the page, using the DOM.
That said, you might not want to do this, nor use IFrames, for SEO reasons! (Also, your pages would not fail gracefully if the client disabled JavaScript.)
To me it seems better to have a more search-engine-friendly page and put up with the transmission of duplicate markup. Server Side Includes (or any server-side scripting language) would give these qualities while also making it easy for you to change the boilerplate on all pages at once.