Difficulty:Average

Version:Expression Engine 1.0: 20040523

Buy My Book!

Update July 2008: If you like these tutorials and would like to read more like these, except updated for ExpressionEngine 1.6 and with tons more information, tips, tricks and recommendations, check out my new book, Building Websites with ExpressionEngine 1.6. Available either directly from Packtpub.com or from your local online bookstore (such as Amazon), this book uses the same clear, step-by-step approach found in these tutorials and walks you from the basics of installing ExpressionEngine to everything you need to know to have an ExpressionEngine website you can be proud of. (No prior knowledge of ExpressionEngine assumed).

The toasty website after this tutorial is complete, following path A!
The toasty website after this tutorial is complete, following path B!
The toasty website after this tutorial is complete, following path C!

Right now, you should have a few website pages using HTML and CSS up and running, which you can access via an Internet browser. What you're missing is a menu, to navigate between those pages. This tutorial is going to go through the basics of writing a menu, still using CSS. I will show you how to write both a left hand menu, a right hand menu and a top menu, so you can choose your favourite. That said, it's not possible for me to cover every single possible menu configuration in the world. If you've got stuck adapting my tutorial to fit your website, please leave me a comment with a link to your website and I'll try to help out.

Background Information

A menu is the most important part of any website and you should spend some time thinking about it. Unless visitors can clearly and easily navigate from one page of your site to the next, they will simply leave. It's absolutely critical to think about why people are visiting your site and what they want to find. Be careful to organise your menu well - personally I think simplicity is key. The more links you have, the more chances someone will click on something they don't want, get frustrated, and leave. I also think it's important to explain where your links go. If you have a link labelled "Search", most visitors will be expecting a search box. They won't be too happy if you link them to Google. So, write "Link to Google in Russian" or "Search my site". Be as specific as you can, but don't waffle. Worse yet, don't open up your links in new pages. Most people are quite capable of opening their own new windows if they want them, or using the back button if they want to come back to your website. Finally, your menu should be clearly located so that people can instantly find it. The chances of someone finding exactly what they want on the first page they visit is slim - they need to know what their options are fast. Keep your menus consistent between pages too - don't move it around the page unnecessarily. Sometimes it helps to look at other websites for inspiration. Check out the worlds worst website to keep you on the straight and narrow.

Instructions

At this stage, I'm going to assume you know how to log into the control panel and edit templates, and that you know a little bit about HTML and CSS from earlier tutorials...

Edit a HTML template...

A menu is really just a list of items, so we put it into an unordered list. This isn't obligatory. Remember that a DIV tag is used only to label different parts of your page: each opening <div> tag needs a corresponding closing </div> tag.

<div id="header">

<h1>History of Toast</h1>

</div>

<div id="menu">

<ul>

<li><a href="http://www.leoandmeg.com/welcome/site/" title="My toast site welcome page - the first port of call for all things toasty">Welcome</a><div class="description">Get your toasty warm welcome here</div></li>

<li><a href="http://www.leoandmeg.com/welcome/site/history/" title="A brief history of all things toasty">History of Toast</a><div class="description">From sliced bread to the modern day: a look at toast over the centuries</div></li>

</ul>

</div>

<div id="content">


If ever you want to compare your code with mine, you can always view the source of my toast website: in Internet Explorer click View and then Source to get a text file of my code.

A rather basic menu...

In our next tutorial, I'll show you how to use sub-templates so you don't need a copy of your menu in every template

The revision history records every update since the creation of the template...

The different regions of a menu

Although I will describe 3 very different menus, they all use exactly the same HTML code.

3 menus: top, left and right respectively

Remember that the template notes field is an excellent place to store notes. You might want to write about what the template is for, or how to do something. You can also use it store little snippets of code that you don't want to use just yet.

The template size option in the CSS template: see how I'm using my template notes too

#menu

{

float: left;

position: relative;

margin-left: -1.75em;

margin-top: -1.75em;

margin-right: 0;

}


#menu ul

{

list-style: none;

}


#menu ul li

{

margin: 0.5em;

padding: 0.5em;

text-align: center;

display: inline;

}


On your own site, you might want to change the colour of links using the 'font-color' attribute. I haven't done so here, since I felt that the default colours were adequate enough.

#menu a

{

font-size: 75%;

font-family: Arial, Verdana, "Trebuchet MS", Helvetica, sans-serif;

text-decoration: none;

font-weight: bold;

}

#menu a:hover

{

font-style: italic;

}

#menu a:visited

{

font-size: 75%;

text-decoration: none;

font-weight: normal;

}


.description

{

font-size: 65%;

font-family: Verdana, "Trebuchet MS", Arial, Helvetica, sans-serif;

display: none;

}


Edit a HTML template...

The template size option in the CSS template: see how I'm using my template notes too

#menu

{

width: 9em;

float: right;

position: relative;

padding: 0.5em;

margin-top: 1em;

margin-right: 0;

margin-bottom: 0;

padding-bottom: 0.25em;

border: 1px dashed #666;

background: #eee;

}


#menu ul

{

list-style: none;

}

#menu ul li

{

margin-bottom: 1em;

text-align: center;

margin-left: -2em;

padding-left: -2em;

}


#menu a

{

font-size: 100%;

font-family: Arial, Verdana, "Trebuchet MS", Helvetica, sans-serif;

text-decoration: none;

font-weight: bold;

}

#menu a:hover

{

font-style: italic;

}

#menu a:visited

{

font-size: 100%;

text-decoration: none;

font-weight: normal;

}


.description

{

font-size: 65%;

font-family: Verdana, "Trebuchet MS", Arial, Helvetica, sans-serif;

}


Our right hand menu...

The template size option in the CSS template: see how I'm using my template notes too

#menu

{

width: 12em;

float: left;

position: relative;

margin-top: 1em;

margin-right: 0;

margin-top: 1em;

margin-left: -2em;

}


Remember that I'm no professional tutorial writer - so if I say something that doesn't make sense, or if I contradict myself, let me know! Of course if you don't notice, then I don't mind...

#menu ul

{

list-style: none;

border-top: 1px solid #eee;

}

#menu ul li

{

margin-bottom: 0.5em;

padding-bottom: 0.5em;

padding-top: 0.5em;

text-align: center;

border-bottom: 1px solid #eee;

}


If you're comparing paths b and c (the left and right hand menu), you'll notice no differences between this step (23c) and it's counterpart (17b). You don't have to change much code to get dramatic differences in how your site looks.

#menu a

{

font-size: 100%;

font-family: Arial, Verdana, "Trebuchet MS", Helvetica, sans-serif;

text-decoration: none;

font-weight: bold;

}

#menu a:hover

{

font-style: italic;

}

#menu a:visited

{

font-size: 100%;

text-decoration: none;

font-weight: normal;

}


Once again there are no differences between this step (24c) and it's counterpart (18b).

.description

{

font-size: 65%;

font-family: Verdana, "Trebuchet MS", Arial, Helvetica, sans-serif;

}


Our left hand menu...

Remember that I'm no professional tutorial writer - so if I say something that doesn't make sense, or if I contradict myself, let me know! Of course if you don't notice, then I don't mind...

#menu ul

{

list-style: none;

border-top: 1px solid #eee;

}

#menu ul li

{

margin-bottom: 0.5em;

padding-bottom: 0.5em;

padding-top: 0.5em;

text-align: center;

border-bottom: 1px solid #eee;

}


If you're comparing paths b and c (the left and right hand menu), you'll notice no differences between this step (23c) and it's counterpart (17b). You don't have to change much code to get dramatic differences in how your site looks.

#menu a

{

font-size: 100%;

font-family: Arial, Verdana, "Trebuchet MS", Helvetica, sans-serif;

text-decoration: none;

font-weight: bold;

}

#menu a:hover

{

font-style: italic;

}

#menu a:visited

{

font-size: 100%;

text-decoration: none;

font-weight: normal;

}


Once again there are no differences between this step (24c) and it's counterpart (18b).

.description

{

font-size: 65%;

font-family: Verdana, "Trebuchet MS", Arial, Helvetica, sans-serif;

}


Our left hand menu...

Remember that I'm no professional tutorial writer - so if I say something that doesn't make sense, or if I contradict myself, let me know! Of course if you don't notice, then I don't mind...

#menu ul

{

list-style: none;

border-top: 1px solid #eee;

}

#menu ul li

{

margin-bottom: 0.5em;

padding-bottom: 0.5em;

padding-top: 0.5em;

text-align: center;

border-bottom: 1px solid #eee;

}


If you're comparing paths b and c (the left and right hand menu), you'll notice no differences between this step (23c) and it's counterpart (17b). You don't have to change much code to get dramatic differences in how your site looks.

#menu a

{

font-size: 100%;

font-family: Arial, Verdana, "Trebuchet MS", Helvetica, sans-serif;

text-decoration: none;

font-weight: bold;

}

#menu a:hover

{

font-style: italic;

}

#menu a:visited

{

font-size: 100%;

text-decoration: none;

font-weight: normal;

}


Once again there are no differences between this step (24c) and it's counterpart (18b).

.description

{

font-size: 65%;

font-family: Verdana, "Trebuchet MS", Arial, Helvetica, sans-serif;

}


Our left hand menu...

Remember that I'm no professional tutorial writer - so if I say something that doesn't make sense, or if I contradict myself, let me know! Of course if you don't notice, then I don't mind...

#menu ul

{