<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lost Resort Blog &#187; floating elements for navigational menu</title>
	<atom:link href="http://www.lostresort.biz/blog/tag/floating-elements-for-navigational-menu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lostresort.biz/blog</link>
	<description>Talking about us and about web site development</description>
	<lastBuildDate>Thu, 08 Jul 2010 11:34:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Building horizontal navigation menus</title>
		<link>http://www.lostresort.biz/blog/2009/04/23/building-horizontal-navigational-menus/</link>
		<comments>http://www.lostresort.biz/blog/2009/04/23/building-horizontal-navigational-menus/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 11:04:43 +0000</pubDate>
		<dc:creator>Cristi_N</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[floating elements for navigational menu]]></category>
		<category><![CDATA[horizontal navigation menu]]></category>
		<category><![CDATA[inline elements for navigational menu]]></category>
		<category><![CDATA[navigation menus]]></category>

		<guid isPermaLink="false">http://www.lostresort.biz/blog/?p=376</guid>
		<description><![CDATA[Almost every website on the Internet has a navigational menu constructed horizontally or vertically. Simple or more complex with drop-down sub-items, it&#8217;s presence is necessary to lead the visitor(s) to the desired information inside the website. There are quite enough methods to build navigational menus, and I&#8217;ll give my opinion on few of them. Use [...]]]></description>
			<content:encoded><![CDATA[<p>Almost every website on the Internet has a navigational menu constructed horizontally or vertically. Simple or more complex with drop-down sub-items, it&#8217;s presence is necessary to lead the visitor(s) to the desired information inside the website. There are quite enough methods to build navigational menus, and I&#8217;ll give my opinion on few of them.</p>
<h3>Use of table for building the menu</h3>
<p>HTML element <code><</code>table<code>></code> has the advantage of being well implemented in all major browsers, so no displaying issues when it's content is deployed. The idea is simple, to create only one table row, with one data cell for each item menu. Using the CSS style attributes the menu will get the appearance it needs.</p>
<p>The HTML code is a follows:</p>
<blockquote><p>
                       <code><</code>table<code>></code><br />
				<code><</code>tr<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>Item 1<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>Second Item<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>Third One<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>Item 4<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>Fifth in the row<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>td<code>></code><code><</code>a href=""<code>></code>LastItem<code><</code>/a<code>></code><code><</code>/td<code>></code><br />
				<code><</code>/tr<code>></code><br />
			<code><</code>/table<code>></code>
</p></blockquote>
<p>We can add some style to the table appearance and be sure you set the <code>border-collapse</code> property to <code>collapse</code> so no spaces are between data cells and borders are collapsed into a single border when possible. A detailed presentation of this style property can be found at <a href="http://www.w3schools.com/Css/pr_tab_border-collapse.asp" title="W3 Schools CSS border-collapse property">W3 Schools CSS border-collapse property</a> page.</p>
<h3>Using unordered list items to create navigational menu</h3>
<p>Using the items of an unordered list to create the navigational menu is, maybe, the most used technique.<br />
Comparing with the previous method it requires almost the same number of lines for CSS styles, and the effect is similar. To display items horizontally you can use the <code>display:inline</code> style property, so the elements of the unordered list are displayed in the same line, like a row of elements. Setting the item elements to be displayed as inline elements, make them "unmovable" on y axis, which means that using padding or margin property to arrange the way they are displayed has no effect. But giving some values to <code>height</code> or/and <code>line-height</code> properties this issue can be easily handled.</p>
<p>Another way to display the elements on the same row is to float the list-items of the unordered list to left. This method tends to be more desired then the previous and the result is much similar with the menu created using table elements.</p>
<p>Following the next link you can see <a href="http://www.lostresort.biz/examples/build-navigational-menu/build-horizontal-menu.html" title="Building horizontal navigational menu">a few examples of horizontal navigational menus</a> using the methods described above. I left the style properties unaltered so you can see on different web browser how the menus are displayed. </p>
<h3>Adding some graphic style to the menu</h3>
<p>Using background images for the elements of the menu creates a nice and more desired visual effect. Even if you use a repeated background image or you create a little more sophisticated rounded corner button for your menu you definitely add a bit of color to the (maybe) flat HTML page. In the next line I'll give some hints on how to create these rounded corner buttons.</p>
<h3>Creating rounded corner buttons for the navigational menu</h3>
<p>The simplest approach may be to create a button with a given width and height and use it as a background image for each item of the menu. This will work fine in situations when the text of the menu items has the same length or the differences are insignificant.</p>
<h4>Split image for the background</h4>
<p>Another method is to split the images in two parts and build the menu items using besides the <code>anchor</code> element an additional <code>span</code> element. The code for the menu will look like:</p>
<blockquote><p>
                       <code><</code>ul id="split"<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Item 1<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Second Item<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Third One<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Item 4<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Fifth in the row<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code>Last Item<code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
			<code><</code>/ul<code>></code>
</p></blockquote>
<p>The idea is to set the <code>display:block</code> property for <code>anchor</code> and <code>span</code> elements, and using the <code>padding</code> values the items are displayed correctly with the desired effect, which means that the width of each item will follow the length of the text. Note that the image on the right side in this case should have a width which is greater than the length of the text with the values for the left and right padding added; otherwise the background image will be broken.</p>
<h4>Using two <code>span</code> elements for the right and left margins</h4>
<p>In this case the image is split in three parts, one for the right margin, second for the left margin and the third one for the middle. This last one image may have a width as small as possible, because it can be repeated on x axis. The HTML code of the menu will be as follows:</p>
<blockquote><p>
                       <code><</code>ul id="split3"<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Item 1<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Second Item<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Third One<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Item 4<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Fifth in the row<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
				<code><</code>li<code>></code><code><</code>a href=""<code>></code><code><</code>span<code>></code><code><</code>span<code>></code>Last Item<code><</code>/span<code>></code><code><</code>/span<code>></code><code><</code>/a<code>></code><code><</code>/li<code>></code><br />
			<code><</code>/ul<code>></code>
</p></blockquote>
<p>The good part for this method is that the padding values can be set just for the last <code>span</code> element, and this is enough to reach the desired effect. Even we have more CSS and HTML code for this last method I think is more simple than the previous one, because you don't have to tweak <code>padding</code> values to have all elements aligned.</p>
<p>Please follow this link to see (and download files) examples of <a href="http://www.lostresort.biz/examples/build-navigational-menu/build-horizontal-menu.html" title="Building horizontal navigational menu">building navigational menus</a> using the method I've described.</p>
<p><strong>The resulted page was tested on Firefox v3.0.9., Internet Explorer v6.0, v7.0 and v8.1, Opera v9.63, Safari v3.2.1 and Google Chrome.</strong></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.lostresort.biz%2Fblog%2F2009%2F04%2F23%2Fbuilding-horizontal-navigational-menus%2F&amp;linkname=Building%20horizontal%20navigation%20menus"><img src="http://www.lostresort.biz/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.lostresort.biz/blog/2009/04/23/building-horizontal-navigational-menus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
