<?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>monkeyflash.com &#187; HTML &amp; CSS</title>
	<atom:link href="http://monkeyflash.com/category/html-css/feed/" rel="self" type="application/rss+xml" />
	<link>http://monkeyflash.com</link>
	<description>Greg Lunn's blog, with tutorials on Flash, CSS, ActionScript and more.</description>
	<lastBuildDate>Wed, 31 Dec 2008 18:13:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Aligning List Bullet Images</title>
		<link>http://monkeyflash.com/tutorials/aligning-list-bullet-images/</link>
		<comments>http://monkeyflash.com/tutorials/aligning-list-bullet-images/#comments</comments>
		<pubDate>Tue, 10 Oct 2006 17:36:00 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://beta.monkeyflash.com/?p=55</guid>
		<description><![CDATA[Recently, I fought another browser inconsistency battle over the placement of image bullets to the left of an unordered list.  While Firefox places the bullets where I expect, Internet Explorer places them too high, moving them out of alignment with the text. IE also occasionally moves the text too close to the bullet, and [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I fought another browser inconsistency battle over the placement of image bullets to the left of an unordered list.  While Firefox places the bullets where I expect, Internet Explorer places them too high, moving them out of alignment with the text. IE also occasionally moves the text too close to the bullet, and refuses to move it no matter what styles I apply. It&#8217;s only a minor difference, but in some cases this misalignment can become disorienting to the user.<span id="more-55"></span></p>
<h3>What&#8217;s going on here?</h3>
<p>The inconsistency occurs because the browsers disagree over where to position the <code>list-style-image</code> attribute, which is used to create custom bullets within an unordered list. I tried several small solutions, such as adjusting the <code>line-height</code> of the text or adding additional margins and padding, but these either had no effect or created even more inconsistencies.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#2a245b</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1.4</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">list-style-image</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">star.gif</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p class="image"><img src="/images/bulletlist1.gif" alt="Bullet list as displayed in Firefox and IE." /></p>
<p class="caption">Firefox (left) displays the list as expected, but Internet Explorer causes the bullet image to shift up and to the right.</p>
<p>Eventually, I decided to find another way to create the same effect without using <code>list-style-image</code>, and I found a solution that worked.</p>
<h3>Let&#8217;s try something else</h3>
<p>Since the browsers don&#8217;t agree on the position of the bullets, either in their default form or as an image, I did away with them entirely by using <code>list-style-type:none;</code>. This leaves me with a bare list, so it&#8217;s time to replace the bullet some other way.</p>
<p>I decided to place a background image in each of the list items and add just enough padding on the left side to make room for the image. This way, I can precisely control the display of the bullet using <code>background-position</code> if necessary, and place the text consistently where I want by using just the right amount of <code>padding-left</code>. This method still produces a standards-based accessible list, while creating a consistent web page across all modern browsers.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#2a245b</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1.4</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
li <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">star.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p class="image"><img src="/images/bulletlist2.gif" alt="New version as displayed in both browsers." /></p>
<p class="caption">Both browsers display this version almost identically.</p>
<h3>A different approach</h3>
<p>You will frequently run into similar scenarios when developing CSS-based layouts, and often the answer isn&#8217;t the addition of more elements and styles. You can usually solve little inconsistencies by finding a different method to create the same effect &#8211; one that all browsers will render correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://monkeyflash.com/tutorials/aligning-list-bullet-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Image Rollover Navbar</title>
		<link>http://monkeyflash.com/tutorials/css-image-rollover-navbar/</link>
		<comments>http://monkeyflash.com/tutorials/css-image-rollover-navbar/#comments</comments>
		<pubDate>Fri, 30 Jun 2006 17:31:11 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://beta.monkeyflash.com/?p=53</guid>
		<description><![CDATA[Wouldn&#8217;t it be really cool if there were a way to create an image rollover that doesn&#8217;t require preloading images or JavaScript? Wouldn&#8217;t it be great if you could create horizontal or vertical navigation using only a clean unordered list markup in your HTML? How about having both of them, together?
Let&#8217;s take a look at [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be really cool if there were a way to create an image rollover that doesn&#8217;t require preloading images or JavaScript? Wouldn&#8217;t it be great if you could create horizontal or vertical navigation using only a clean unordered list markup in your HTML? How about having both of them, together?</p>
<p>Let&#8217;s take a look at the HTML code we will use for this example. I wanted to keep the code as clean as possible, while making it possible to arrange the display of the items in a variety of ways.<span id="more-53"></span> Both the vertical and horizontal navigation will be based in this simple list.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navlist&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Menu Item 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Menu Item 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Menu Item 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Menu Item 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<h3>Creating Pure CSS Rollovers</h3>
<p>Using CSS, image rollovers can be created using only a single image that is loaded when the page is called, eliminating the need to preload images using JavaScript. To create this effect, you&#8217;ll need to create images that contain the two or three states of your rollover within the same file.</p>
<p><img src="/images/rolloverimages.gif" alt="Rollover images, each with three states." style="border:none;"/></p>
<p>Once the images are ready, they are loaded into a container element, in this case the <code>&lt;a&gt;</code> tag, as a background image and cropped using the <code>&lt;a&gt;</code> tag&#8217;s width and height. Then it&#8217;s simply a matter of using the <code>background-position</code> property to move the image within the container to simulate the image swap effect.<br />
<style type="text/css"><!--#navlist { font-family:Arial, Helvetica, sans-serif; font-size:1.1em; font-weight:bold; list-style:none; padding:10px 5px; background:url(/images/bk.gif) repeat-y; border:2px solid #4e6b94; width:155px; float:right; margin:0 0 0 10px;} #navlist a {display:block; width:135px; color:#fff; text-decoration:none; background:url("/images/tab.gif") no-repeat; padding:4px 10px 2px 10px; } #navlist a:hover { background-position:0 -29px; color: #1e5ebd; } #navlist a:active { background-position:0 -58px; color:#1e5ebd;} #navlist li {background-image:none;padding:0;} --></style>
<h3>Vertical Navigation</h3>
<ul id="navlist">
<li><a href="#navlist">Menu Item 1</a></li>
<li><a href="#navlist">Menu Item 2</a></li>
<li><a href="#navlist">Menu Item 3</a></li>
<li><a href="#navlist">Menu Item 4</a></li>
</ul>
<p>First, let&#8217;s take a look at the CSS used to create a vertical navigation menu from the list. It&#8217;s really a simple matter of converting the display of the <code>&lt;a&gt;</code> tags to <code>display:block;</code>, and providing them with the proper width and height to display a single &#8220;state&#8221; from our image. The <code>hover</code> and <code>active</code> pseudo-classes are then used to move the <code>background-position</code> to simulate the rollover effect, as seen to the right. Remember to also remove the bullets by using <code>list-style:none;</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navlist</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">.8em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> a <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">135px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;images/tab.gif&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span> <span style="color: #933;">10px</span> <span style="color: #933;">6px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-29px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#1e5ebd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> a<span style="color: #3333ff;">:active </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-58px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#1e5ebd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>How About Horizontal Tabs?</h3>
<p>Using the same HTML, we can create a horizontal list with the appearance of tabs by using a different image, and adjusting the CSS.  Note that the only real differences in this from the vertical example are that instead of setting the <code>&lt;a&gt;</code> tags to block, we use <code>float:left;</code> to place them to the right of one another. Also, we use <code>display:inline;</code> on the <code>&lt;li&gt;</code> tags to get them to display horizontally, which has the added benefit of automatically removing the bullets. (See the earlier article, <a href="http://www.monkeyflash.com/archives/2006/06/20/simple-horizontal-navbar-list/">Simple Horizontal Navbar List</a>, for another example.)</p>
<p>Here is the CSS, adjusted for a horizontal display.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navbar</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">.8em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navbar</span> li <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navbar</span> a <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">110px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;images/tab2.gif&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> <span style="color: #933;">10px</span> <span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navbar</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-45px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#1e5ebd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navbar</span> a<span style="color: #3333ff;">:active </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-90px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#1e5ebd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The result is the horizontal tabbed menu below:<br />
<style type="text/css"><!-- #navbar { font-family:Arial, Helvetica, sans-serif; font-size:1.2em; font-weight:bold; padding:10px 20px; background:url(/images/bk2.gif) repeat-x; height:45px; border:2px solid #4e6b94; width:476px; margin-left:0;} #navbar li { list-style:none; display:inline; } #navbar a { width:110px; color:#fff; text-decoration:none; background:transparent url("/images/tab2.gif") no-repeat; float:left; padding:10px 10px 9px; margin:0 -10px;} #navbar a:hover { background-position:0 -45px; color:#1e5ebd; } #navbar a:active { background-position:0 -90px; color:#1e5ebd;} #navbar li {background-image:none;padding:0;} --></style>
<ul id="navbar">
<li><a href="#navbar">Menu Item 1</a></li>
<li><a href="#navbar">Menu Item 2</a></li>
<li><a href="#navbar">Menu Item 3</a></li>
<li><a href="#navbar">Menu Item 4</a></li>
</ul>
<p><strong>Note:</strong> In the examples displayed on this page, I&#8217;ve also included background images in the parent <code>&lt;ul&gt;</code> lists and additional padding, solely for appearance and easier recognition of the edges of the rollovers. Depending on the appearance of your buttons, this method may or may not be desirable, but will not affect the technique described here. You can see the examples on their own by downloading the <a href="/files/rolloverdemo.zip">example files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://monkeyflash.com/tutorials/css-image-rollover-navbar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Horizontal Navbar List</title>
		<link>http://monkeyflash.com/tutorials/simple-horizontal-navbar-list/</link>
		<comments>http://monkeyflash.com/tutorials/simple-horizontal-navbar-list/#comments</comments>
		<pubDate>Tue, 20 Jun 2006 17:25:16 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://beta.monkeyflash.com/?p=50</guid>
		<description><![CDATA[One of the simplest and most efficient forms of navigation for a website is the horizontal list of items, separated by the pipe (&#124;) symbol. Unfortunately, marking up a &#60;p&#62; tag with the pipe character in between links is messy and not very accessible. A more efficient method to solve this problem is to use [...]]]></description>
			<content:encoded><![CDATA[<p>One of the simplest and most efficient forms of navigation for a website is the horizontal list of items, separated by the pipe (|) symbol. Unfortunately, marking up a <code>&lt;p&gt;</code> tag with the pipe character in between links is messy and not very accessible. A more efficient method to solve this problem is to use an unordered list to markup the navigation links. We can then use CSS to style the vertical list horizontally and add the appropriate separators.<span id="more-50"></span></p>
<h3>Start with an HTML list</h3>
<p>There are many ways to accomplish the effect we&#8217;re going for here, and some result in even cleaner HTML than this example. There are many impressive list conversions at <a href="http://css.maxdesign.com.au/listamatic/">Listamatic</a> for a variety of needs. This example will create a centered, horizontal set of HTML links separated by a vertical bar.</p>
<p>Our HTML markup looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navlist&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Products<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Store<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>About<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;last&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Contact Us<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>Overall, a very clean markup that&#8217;s easy to update and maintain. Notice that this markup does not contain the pipe symbol &#8211; we&#8217;ll add the separator using CSS. Although there are differences of opinion about whether or not the pipe character should be part of the content, my main reason for leaving it out of the HTML is to prevent screen readers like <a href="http://www.freedomscientific.com/fs_products/software_jaws.asp">JAWS</a> from awkwardly announcing a &#8220;vertical bar&#8221; after each list item.</p>
<p>The HTML contains only one <code>id="navlist"</code>, so that we can apply styles to this list in particular. It also contains one <code>class="last"</code> that we will use later to eliminate the extra separator.</p>
<h3>Blend in some nice CSS</h3>
<p>To convert an unordered list to a horizontal menu requires only a few CSS rules. Let&#8217;s take a look:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navlist</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">.9em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#009</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>We begin by adjusting each <code>&lt;li&gt;</code> to <code>display:inline</code>, which forces the list items to display horizontally and removes the bullet point from the front of each. After adding a little left and right side padding, we replicate the effect of a vertical bar by adding a 1px <code>border</code> to the right side of each list item.</p>
<p class="image"><img src="/images/navbar1.gif" alt="Navbar displayed horizontally" /></p>
<p class="caption">The navbar is horizontal, but it still has an extra right border.</p>
<p>At this point, we have a functional horizontal navbar, but it has an extra right border hanging off of the end. To remove this extra border, I simply created the <code>.last</code> class and assigned it a value of <code>border:none</code>. It&#8217;s my least favorite part of the technique because of the extra class markup in the HTML, but I think it&#8217;s the best option to ensure that the entire list can be centered.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navlist</span> li<span style="color: #6666ff;">.last</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Verdana</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">.7em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#009</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navlist</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#39F</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The final CSS rules apply text formatting to the list, center the entire list, and ensure link and hover states behave in a suitable manner. These are completely adjustable for your particular needs. For instance, I would most likely choose a smaller font size if I were using this technique for a footer.</p>
<p class="image"><img src="/images/navbar2.gif" alt="The finished horizontal navbar." /></p>
<p class="caption">The finished horizontal navbar.</p>
<p>Our finished navbar behaves consistently across browsers and maintains a very high degree of accessibility, while providing an easy-to-use and visually pleasing navigation scheme.</p>
]]></content:encoded>
			<wfw:commentRss>http://monkeyflash.com/tutorials/simple-horizontal-navbar-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
