Home arrow HTML arrow Page 4 - HTML for a Common Browser Menu
HTML

HTML for a Common Browser Menu


In this part of the series I describe the HTML elements and their attributes. I do not talk about the events in this part; I will talk about the events in a later part. I will also talk about the CSS for the menu elements and sub menu elements. Throughout the series, we shall use the example that was described in the previous part.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
March 13, 2009
TABLE OF CONTENTS:
  1. · HTML for a Common Browser Menu
  2. · More on the Elements and Attributes
  3. · The Table Cell Contents in the DIV
  4. · The Style Sheet

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
HTML for a Common Browser Menu - The Style Sheet
(Page 4 of 4 )

We have already seen the style for the DIV element. The styles for the other elements are in the style sheet. This is the style sheet:


<style type="text/css">

body {background-color:#ff9933}

h1 {text-align:center}

td.link {width:160px; height:20px; background-color:brown; border-width:0px;padding:0px; margin:0px}

td.drop {width:20px; height:20px; background-color:SaddleBrown; color:darkOrange; border-width:0px;padding:0px; margin:0px}

button.drop {width:18px; height:18px; background-color:SaddleBrown; color:darkOrange; border:1px solid darkred; padding:0px; margin:0px}

td.sub {width:180px; height:20px; background:transparent; border-width:0px;padding:0px; margin:0px}

A:link {color:gold; text-decoration:none}

A:visited {color:khaki}

A:hover {color:LemonChiffon; text-decoration:underline}

A:active {color:yellow}

</style>


Later in the series, I will give you the complete code for the example. In that code, and as you can see from the style sheet above, the BODY element has a background color of :#ff9933. There is an H1 element, and it is aligned at the center of the page. The third line in the CSS above applies to the cells with links in the main menu. For simplicity and consistency between browsers, the border width is zero, padding: zero, and margin: zero. The background color is brown. The width and height are also given.

The next statement is for the table cells that have the drop-down buttons. Note the properties and values. Again, for simplicity and consistency, we have zero border, zero padding and zero margin.

The next statement applies to the drop-down buttons. Note the properties and values. Again, for simplicity and consistency we have zero padding and zero margin. However, we now have a border of 1px with the dark-red color. We have also given the button a background color. The button then appears differently from a normal button. The appearance is chosen to match the looks of the menu. Recall that borders add extra size to the size of an element. You have to do your calculation well, so that the button fits into the table cell.

The next statement applies to the table cells in the DIV element. Note the properties and values. Again, for simplicity and consistency we have zero border, zero padding and zero margin. Now when the DIV element is displayed, only certain cell contents are displayed. The DIV element appears in front of the elements behind. For the cells whose contents are not displayed, their backgrounds have to be transparent so the user can see the elements behind them. So, in this statement the background is transparent. That is the initial value.

The rest of the statements in the style sheet apply to the links.

What we have done so far

Our aim is to come up with code for a menu that can work with most if not all modern browsers, without taking the peculiarities of any particular brand into consideration. We are elaborating the case where the main menu is a horizontal bar; after this we shall briefly look at the case where the main menu is a vertical bar.

In the previous part, we looked at the layout of the menu. In this part we have looked at the elements and their attributes. We have also looked at the CSS. You can put all of your CSS in the style sheet, but I advise you to put the initial dimension properties and their values in the attribute of the tag of the HTML element.

I'll see you in the next part.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials