Creating menubar using HTML and CSS

Simple menubar using HTML and CSS

Simple menubar using HTML and CSS

Menu bar or navigation bar is a a collection of list items. Menu bar can be either horizontal or vertical. Both types of menubar and menu items are created using HTML list items.  Let us see how we can create menubars easily using HTML and CSS.

Unordered list items are created using <ul> and list items created using <li> . These two HTML tags are used to create menubar and menu items. Within each <li> tag there should be one <a> tag referencing to other links.

Vertical Menubar

Following example shows how to create vertical menubar using <ul> and <li> elements.  Within each <li> elements there is a <a> that is linking to different pages. This is how we create menu items.

Vertical Menubar 0

Creating a simple list is enough to create a vertical menubar .

 Horizontal Menubar

Following example shows how to create a horizontal menubar using HTML and CSS.

Horizontal Menubar 0

If you look at the code, some amount of CSS has been added to make list items to display horizontally and display as menubar.

The first is list-style-type is set to none.

Secondly instead of arranging list items as block, they are made to arrange as inline.

Thirdly to beautify the menu elements <a> tags are displayed as block and given a background colour.

You can play with CSS to alter the design of menus in many different ways.  As each website has atleast one menubar it is always useful to know how to create menubar and play with them to create wonderful menubar designs.

Leave a Reply