Collected by Elizabeth Janson Home Page |
|
Navigation Bars with CSSCommonly, where a site comprises a number of pages, or sections, a "navigation bar" is placed at the top and or the bottom of each page that allows readers to easily go to other sections of the site which interest them. A navigation bar can be distinguished by its background color, distinctive link appearance, and by a border which separates it from the surrounding page.To create such a navigation bar we need to create a paragraph which contains the links to be navigated, then add to our style sheet so that the bar has the required features. In the HTML, our navigation bar only needs to be a paragraph, with the necessary links. The one addition is that the paragraph should be of a particular class, so that we can apply style to that paragraph alone, and not the other paragraphs in the page. For this page, our navigation bar HTML looks like this <p class="navigation-bar"> <A HREF="01intro.html">Intro</A>, | <A HREF="02syntax.html">Syntax</A>, | <A HREF="03selector.html">Selectors</A>, | <A HREF="04css.html">Style</A>, | <A HREF="05font.html">Font</A>, | <A HREF="06text.html">Text</A>, | <A HREF="07colour.html">Colour</A>, </p> The paragraphbackground color using - text alignment using - borders using - padding is needed to aid legibility, so that there is some space between the edges of the element and the text. The linksWe still need to create the style sheet rule for the links in our navigation bar. We can't simply apply style to all the links on our page, as not all of them are in the navigation bar. You might think that we need to create a new class for the links in the navigation bar. But wouldn't it be nice if we could select only links inside paragraphs of class navigation bar? Well we can (you knew I was going to say that didn't you?) Here it is. We need a slightly different type of selector. This one lists the container element, then the element that is contained inside it. In this case P.navigation-bar A:link
and so on.
|
Email CSS begins here |
|
This page is part of Elizabeth Janson's web site
http://www.oocities.org/elizatk/index.html
Tetbury residents in the Eighteenth Century my Australian Family History and Barrie, our Family Poet. |