<?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>freeyourdesign &#187; css menu</title>
	<atom:link href="http://freeyourdesign.com/tag/css-menu/feed/" rel="self" type="application/rss+xml" />
	<link>http://freeyourdesign.com</link>
	<description>break free by learning</description>
	<lastBuildDate>Wed, 06 Oct 2010 19:32:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>CSS Horizontal Menu</title>
		<link>http://freeyourdesign.com/css/css-horizontal-menu/</link>
		<comments>http://freeyourdesign.com/css/css-horizontal-menu/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 12:51:56 +0000</pubDate>
		<dc:creator>fyd</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[css menu]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://freeyourdesign.com/css/css-horizontal-menu/</guid>
		<description><![CDATA[Let's use CSS to make a Horizontal Menu. We will be using and styling an unordered list for our menu. There's not a lot to it and the code has comments by each line &#8211; so just follow along and you'll have your own menu in no time. So, make a new .css file and [...]]]></description>
			<content:encoded><![CDATA[<p>Let's use CSS to make a Horizontal Menu. We will be using and styling an unordered list for our menu. There's not a lot to it and the code has comments by each line &#8211; so just follow along and you'll have your own menu in no time.<br />
So, make a new .css file and name it style.css &#8211; You can use notepad and save the file as .css instead of .txt</p>
<h3>Main Container</h3>
<p>We start off with our main styling container. In it we will setup styles like the width of our menu &#8211; the background color &#8211; font size &#8211; and tell it we don't want any bullets next to our list items.</p>
<pre>
<span class="text">/* main container - ul id="menu" */
</span>#menu
{
	margin: 0; <span class="text">/* reset the margins */</span>
	padding: 0; <span class="text">/* reset the padding */</span>
	width: auto; <span class="text">/* this size depends on your menu */</span>
	float: left; <span class="text">/* line things up */</span>
	font-size: 1.4em; <span class="text">/* increase the font size a bit */</span>
	background: #656565; <span class="text">/* any background color you want */</span>
	list-style: none; <span class="text">/* no bullets on our list items */</span>
}</pre>
<h3>The List Items</h3>
<p>Now we will style the list items. If you have items in your menu that aren't linked then this is where you would add any extra formatting for those. Most of the time everything in a menu is linked so all we need to do for our menu is tell it to display our items horizontally.</p>
<pre>
<span class="text">/* list elements */</span>
#menu li
{
	display: inline; <span class="text">/* make it horizontal */</span>
}</pre>
<h3>Our Links</h3>
<p>Let's style our links. This is where we put in formatting like the color of our links &#8211; text decorations &#8211; and anything else you want. The padding here is important and is used to give extra space around the words &#8211; without it the menu would take the height of just slightly more than the text. The a:visited is added to make the links stay the same color even if the user has already visited a link.</p>
<pre>
<span class="text">/* style our links */</span>
#menu li a:link, #menu li a:visited
{
	float: left; <span class="text">/* line things up */</span>
	color: #ffffff; <span class="text">/* the color of our linked items */</span>
	padding: 10px 10px; <span class="text">/* spread it out */</span>
	text-decoration: none; <span class="text">/* no underline */</span><span class="text">/* white border to the right of link</span>
	*/
	border-right: 1px solid #ffffff;
}</pre>
<h3>Link Hover</h3>
<p>Now we format how the link will look when our mouse hovers over it.</p>
<pre>
<span class="text">/* style link hover */</span>
<span class="text">/* .active_link class - optional -</span>
styles the current pages link */
#menu li a:hover, #menu li a:active, #menu .active_link
{
	text-decoration: none; <span class="text">/* no underline */</span>
<span class="text">	/* color to change to when we hover over link */</span>
	background: #009900;
}</pre>
<h3>Clear The Left Margin</h3>
<p>We had float: left above so we need to clear out the left margin so the rest of our page items will fall under our menu instead of to the right of it.</p>
<pre>
<span class="text">/* optional - but a good class to have in every stylesheet */</span>
<span class="text">/* we had float:left; above so in order to clear out the</span>
left margin and allow elements on our page to start under
our menu we should clear the left margin after we creat the menu
*/
.clearLeft
{
	clear: left;
}</pre>
<h3>The HTML</h3>
<p>Open a new HTML file and add a link to our style sheet somewhere within the &lt;head&gt;&lt;/head&gt; tags.</p>
<pre>
&lt;head&gt;
&lt;link href="sytle.css" rel="stylesheet" type="text/css"
media="screen" / &gt;
&lt;/head&gt;</pre>
<p>Within the &lt;body&gt; tags we will setup our menu. Remember we are using an unordered list for our menu.</p>
<pre><span class="text">&lt;!-- use an unordered list --&gt;</span>
&lt;ul id="menu"&gt;
	<span class="text">&lt;!-- each link goes in a list element --&gt;
	&lt;!-- class active_link would be moved to the link of
		whatever page you are on --&gt;
	&lt;!-- so if you if this was the About Us page you would
		move the class="active_link"
		within the About Us a href --&gt;</span>
	&lt;li&gt;&lt;a href="csshzmenu.html" class="active_link"&gt;<span class="text">Home</span>&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;<span class="text">About Us</span>&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;<span class="text">Link 3</span>&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;<span class="text">Link 4</span>&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
<span class="text">&lt;-- clear out left margin -
       see stylesheet for more info --&gt;</span>
&lt;div class="clearLeft"&gt;&lt;/div&gt;</pre>
<p>There you have it &#8211; customize it to your liking and add it to your site. Here are the files for download (right-click save as)<br />
<a href="http://freeyourdesign.com/images/files/hzmenu/csshzmenu.html">THE HTML</a><br />
<a href="http://freeyourdesign.com/images/files/hzmenu/style.css">THE CSS</a></p>
<img src="http://freeyourdesign.com/?ak_action=api_record_view&id=23&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://freeyourdesign.com/css/css-horizontal-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

