The header page: banner and menu
The header page is written once and shown on every page. It has two divisions. The first holds the banner: an img tag with a width and a height so that it always takes the same space. The second holds the menu: the six links Main, Add, Search, Edit, Delete and Help, each pointing to one of the site’s files. The links need some space between them. A browser squeezes ordinary spaces together, so the book separates the links with , a non-breaking space. It works, but it is a crude trick: styling rules (CSS) give cleaner, adjustable spacing, and you will meet them later. Remember Week 4: every page includes this file with one line, so a change to the menu is made in one place. Note that header.php holds only these two divisions; the page that includes it keeps its own html, head and body tags.
1<div> 2<img src="images/banner.webp" alt="Illustrated Dictionary banner" width="600" height="120"> 3</div> 4<div> 5<a href="index.php">Main</a> 6<a href="add_term.php">Add</a> 7<a href="search_term.php">Search</a> 8<a href="edit_term.php">Edit</a> 9<a href="del_term.php">Delete</a> 10<a href="help.php">Help</a> 11</div>
The page shows the banner picture, 600 wide and 120 high, and under it one row of six links: Main, Add, Search, Edit, Delete, Help.
| Menu word | File it opens |
|---|---|
| Main | index.php |
| Add | add_term.php |
| Search | search_term.php |
| Edit | edit_term.php |
| Delete | del_term.php |
| Help | help.php |
1<body> 2<?php include("header.php"); ?> 3<h2>Help</h2> 4</body>
The visitor sees the banner, then the six links, then the heading Help.
Write on paper the two divisions of a header for the reading-club site (a banner and four links: Home, Books, Members, Contact). Give the files they open, then say in one sentence why the links live in one file.