CSS Navigation Bar
CSS Navigation Bar
HOME
HTML
C SS
JAVASC RIPT
JQUERY
XML
ASP.NET
PHP
SQL
MORE...
R EFER ENC ES
EXAMPLES
FO R UM
ABO UT
Get Certified
Study Web Technologies and get a diploma at w3schools.com
Web Designing in 12 mths Le arn HTML, Javascript & Flash Join course at Are na! www.Are na-Multim e dia.com
3D Animation Courses R e giste r Now! Ge t Info on Anim ation C olle ge s, C ourse s, & Studio De tail. HTC am pus.C om /Anim ation+Institute Design logos & websites 12-m onth course to work in m e dia Join MAAC Multim e dia course today! www.m aacindia.com
Like 76k
CSS Basic
CSS HOME CSS Introduction CSS Syntax CSS Id & Class CSS How To
WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email
CSS Styling
Styling Backgrounds Styling Text Styling Fonts Styling Links Styling Lists Styling Tables
Navigation Bars
Having easy-to-use navigation is important for any web site. With CSS you can transform boring HTML menus into good-looking navigation bars.
WEB BUILDING
Download XML Editor FREE Website BUILDER FREE Website C reator Best Website Templates
Example
< u l > < l i > < ah r e f = " d e f a u l t . a s p " > H o m e < / a > < / l i > < l i > < ah r e f = " n e w s . a s p " > N e w s < / a > < / l i > < l i > < ah r e f = " c o n t a c t . a s p " > C o n t a c t < / a > < / l i > < l i > < ah r e f = " a b o u t . a s p " > A b o u t < / a > < / l i > < / u l >
Try it yourself Now let's remove the bullets and the margins and padding from the list:
CSS Advanced
CSS Grouping/Nesting CSS Dimension CSS Display CSS Positioning CSS Floating CSS Align CSS Pseudo-class CSS Pseudo-element CSS Navigation Bar CSS Image Gallery CSS Image Opacity CSS Image Sprites CSS Media Types CSS Attribute Selectors CSS Summary
Example
u l { l i s t s t y l e t y p e : n o n e ; m a r g i n : 0 ; p a d d i n g : 0 ; }
Try it yourself Example explained: list-style-type:none - Removes the bullets. A navigation bar does not need list markers Setting margins and padding to 0 to remove browser default settings The code in the example above is the standard code used in both vertical, and horizontal navigation bars.
CSS Examples
CSS Examples CSS Quiz CSS Certificate
CSS References
CSS Reference CSS Selectors CSS Reference Aural CSS Web Safe Fonts CSS Units CSS Colors CSS Color Values CSS Color Names CSS Color HEX
Example
a { d i s p l a y : b l o c k ; w i d t h : 6 0 p x ; }
Try it yourself Example explained: display:block - Displaying the links as block elements makes the whole link area clickable (not just the text), and it allows us to specify the width width:60px - Block elements take up the full width available by default. We want to specify a 60 px width Tip: Also take a look at our fully styled vertical navigation bar example. Note: Always specify the width for <a> elements in a vertical navigation bar. If you omit the width, IE6 can produce unexpected results.
www.w3schools.com/css/css_navbar.asp
1/3
8/4/13
Example
l i { d i s p l a y : i n l i n e ; }
Try it yourself Example explained: display:inline; - By default, <li> elements are block elements. Here, we remove the line breaks before and after each list item, to display them on one line Tip: Also take a look at our fully styled horizontal navigation bar example.
Example
l i { f l o a t : l e f t ; } a { d i s p l a y : b l o c k ; w i d t h : 6 0 p x ; }
Try it yourself Example explained: float:left - use float to get block elements to slide next to each other display:block - Displaying the links as block elements makes the whole link area clickable (not just the text), and it allows us to specify the width width:60px - Since block elements take up the full width available, they cannot float next to each other. We specify the width of the links to 60px Tip: Also take a look at our fully styled horizontal navigation bar example.
Previous
Next Chapter
Altova MapForce Graphical XML Conversion Tool from the Developers of XMLSpy
Need an easy way to get data into XML, or transform XML to another format? MapForce lets you map XML data to/from any combination of XML, database, flat file, Excel 2007, XBRL, or Web services data. Then it transforms data instantly or auto-generates royalty-free code for recurrent conversions. New features in Version 2013! Easy-to-use, graphical data mapping interface Instant data transformation XSLT 1.0/2.0 and XQuery code generation Java, C#, and C++ code generation Advanced data processing functions Support for all major relational databases including SQL Server, IBM DB2, Oracle, and more Integration with Altova StyleVision for report rendering Visual Studio & Eclipse integration Available in 32-bit and 64-bit versions Download a fully-functional trial today!
Try it now!
www.w3schools.com/css/css_navbar.asp
2/3
8/4/13
Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial
Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors
Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples
Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz
Color Picker
Statistics
Browser Statistics Browser OS Browser Display
RE P O RT E RRO R
HO ME
TO P
P RI N T
FO RU M
A BO U T
A D V E RT I SE WI T H U S
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.
www.w3schools.com/css/css_navbar.asp
3/3