<?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>CreateBetterWebsites.com &#187; Code</title>
	<atom:link href="http://www.createbetterwebsites.com/category/create-a-website-code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.createbetterwebsites.com</link>
	<description>Learn How to Create Better Websites</description>
	<lastBuildDate>Thu, 09 Sep 2010 21:01:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>search-results</title>
		<link>http://www.createbetterwebsites.com/search-results.html</link>
		<comments>http://www.createbetterwebsites.com/search-results.html#comments</comments>
		<pubDate>Wed, 01 Sep 2010 06:47:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=699</guid>
		<description><![CDATA[var googleSearchIframeName = "cse-search-results"; var googleSearchFormName = "cse-search-box"; var googleSearchFrameWidth = 795; var googleSearchDomain = "www.google.com"; var googleSearchPath = "/cse";]]></description>
			<content:encoded><![CDATA[<div id="cse-search-results"></div>
<p><script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 795;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script><br />
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/search-results.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use Contextual Links</title>
		<link>http://www.createbetterwebsites.com/how-to-use-contextual-links.html</link>
		<comments>http://www.createbetterwebsites.com/how-to-use-contextual-links.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 05:52:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[contextual links]]></category>
		<category><![CDATA[create a website]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=655</guid>
		<description><![CDATA[Learn how to use contextual links to your website so that you can achieve better listings on search engines. Using this strategy can also bring you more free and targeted traffic. So what is a contextual link? A contextual link is a link that contains the primary keyword phrase of the page you want to [...]]]></description>
			<content:encoded><![CDATA[<p>Learn how to use contextual links to your website so that you can achieve better listings on search engines. Using this strategy can also bring you more free and targeted traffic.</p>
<h2>So what is a contextual link?</h2>
<p>A contextual link is a link that contains the primary keyword phrase of the page you want to link to.  For example if I want to link to this article then I would create a link that may look like this.</p>
<p><a href="http://www.createbetterwebsites.com/how-to-use-contextual-links.html">Contextual Links</a></p>
<blockquote><p>
&lt;a href=&#8221;http://www.createbetterwebsites.com/how-to-use-contextual-links.html&#8221;&gt;Contextual Links&lt;/a&gt;
</p></blockquote>
<p>I&#8217;ll use this link throughout my own site when I want to link back to this article and also on any other website or external link building strategy.  This will help my page rank well and come up near the top for that particular keyword, contextual links in this case.</p>
<p>But this will only help get good rankings if the keyword you use in the link is also the focus of the page you are linking to.  In other words the content of the page has to be about contextual links in this case and not about hosting or dogs.  You can&#8217;t trick the search engines.  If you try you will get penalized.</p>
<p>Just remember to use contextual links whenever you can to link back to your web pages,  whether it&#8217;s an internal link (from your own website) or external link (from another website).  </p>
<p>Use this technique and you&#8217;ll create a website that ranks well in the search engines and gets free organic traffic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/how-to-use-contextual-links.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Color Codes</title>
		<link>http://www.createbetterwebsites.com/css-color-codes.html</link>
		<comments>http://www.createbetterwebsites.com/css-color-codes.html#comments</comments>
		<pubDate>Wed, 25 Aug 2010 06:19:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=648</guid>
		<description><![CDATA[if (WIDGETBOX) WIDGETBOX.renderWidget('449c32d6-192d-49e0-ac05-cdeaac8e3f77');Get the Farbtastic Widget widget and many other great free widgets at Widgetbox! Not seeing a widget? (More info)]]></description>
			<content:encoded><![CDATA[<p><center><br />
<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript">if (WIDGETBOX) WIDGETBOX.renderWidget('449c32d6-192d-49e0-ac05-cdeaac8e3f77');</script><noscript>Get the <a href="http://www.widgetbox.com/widget/farbtastic-widget">Farbtastic Widget</a> widget and many other <a href="http://www.widgetbox.com/">great free widgets</a> at <a href="http://www.widgetbox.com">Widgetbox</a>! Not seeing a widget? (<a href="http://docs.widgetbox.com/using-widgets/installing-widgets/why-cant-i-see-my-widget/">More info</a>)</noscript><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/css-color-codes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Background Image Codes</title>
		<link>http://www.createbetterwebsites.com/css-background-image-codes.html</link>
		<comments>http://www.createbetterwebsites.com/css-background-image-codes.html#comments</comments>
		<pubDate>Wed, 25 Aug 2010 05:46:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css code]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=643</guid>
		<description><![CDATA[CSS background image codes for displaying a fixed background image on a website.
]]></description>
			<content:encoded><![CDATA[<p>Below are some sample CSS background image codes for displaying a fixed background image on a website.</p>
<p>If you want an image to scroll with your web page use the code below.   Replace filename.jpg with your image name and make sure you put the correct path to the image as well.</p>
<blockquote><p>
body {<br />
background-image: url(filename.jpg);<br />
background-attachment: scroll;<br />
background-repeat: no-repeat;<br />
}
</p></blockquote>
<p>You can also make the background image to be fixed, so when you scroll the webpage up and down, the background image stays static and doesn&#8217;t move.    Replace filename.jpg with your image name and make sure you put the correct path to the image as well.</p>
<blockquote><p>
body {<br />
background-image: url(filename.jpg);<br />
background-attachment: fixed;<br />
background-repeat: no-repeat;<br />
}
</p></blockquote>
<p>If you are using a single image for the background make sure it&#8217;s large enough to cover you web page.  You can also use a small image and repeat it horizontally or vertically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/css-background-image-codes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canonical Link Element</title>
		<link>http://www.createbetterwebsites.com/canonical-lin-element.html</link>
		<comments>http://www.createbetterwebsites.com/canonical-lin-element.html#comments</comments>
		<pubDate>Wed, 18 Aug 2010 20:25:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[canonical]]></category>
		<category><![CDATA[canonicalization]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=629</guid>
		<description><![CDATA[What is a canonical link tag or canonicalization.
It's a link element, an open standard, and is supported by Microsoft, Google, Yahoo. ]]></description>
			<content:encoded><![CDATA[<p>So what is a canonical link element or canonicalization?</p>
<p>It&#8217;s a link element, an open standard, and is supported by Microsoft, Google, Yahoo. </p>
<p>A canonical link element is a way to define a <strong>canonical page</strong> which is the preferred version of a set of pages with very similar or duplicate content. </p>
<p>It fixed all the cracks and mistakes developers make in their code.  </p>
<p>Make all your internal links consistent.  Make sure your URL&#8217;s are standardized or normalized.  In other words don&#8217;t have different versions of your URL&#8217;s in your internal linking.</p>
<p>For example all of the URL&#8217;s below can be the same exact page but search engines will be confused and see them as different pages even if they return the same content.  </p>
<p>Because in practice they can actually return different content depending on the content management system and the web server.</p>
<blockquote><p>www.yourdomain.com<br />
www.yourdomain.com/index.html<br />
www.yourdomain.com/<br />
www.yourdomain.com/index.html/<br />
index.html
</p></blockquote>
<p>The best thing maybe be to always use absolute URL&#8217;s.  For example always point to your home page like so&#8230; </p>
<p>http://www.yourdomain.com/index.html</p>
<p>This way you are consistent and you don&#8217;t confuse the search engines and seem like you have duplicate content.</p>
<p>If you do have different internal linking and or duplicate content that you can&#8217;t fix it then you use the canonical link element in your web pages. </p>
<p>The way to specify the canonical page is to insert the link element like this ..</p>
<blockquote>
<link rel="canonical" href="http://www.domain.com/index.html"/></blockquote>
<p>You can self-reference a page.  Meaning you can insert the above link element in your index.html page and on any page that duplicates the index.html.  When you insert it in index.html it&#8217;s a self reference. </p>
<p>One of the biggest issues I&#8217;ve seen with code and with content management systems sometimes is that the entire site points to the main page.  So all pages are pointing to for example the index page and contain the link code like this.</p>
<blockquote>
<link rel="canonical" href="http://www.domain.com/index.html"/></blockquote>
<p>This can be determental to a site.  I&#8217;ve seen this happen and the entire site is not indexed except for the index.html.  So what do you do in this case?  Remove the line of code and resubmit your website to the search engines.  </p>
<p>Here is an article on <a href="http://www.createbetterwebsites.com/how-to-remove-canonical-links.html">How to Remove Canonical Link Element From Multiple Files.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/canonical-lin-element.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remove Canonical Links</title>
		<link>http://www.createbetterwebsites.com/how-to-remove-canonical-links.html</link>
		<comments>http://www.createbetterwebsites.com/how-to-remove-canonical-links.html#comments</comments>
		<pubDate>Tue, 17 Aug 2010 18:34:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[canonical]]></category>
		<category><![CDATA[canonicalization]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=619</guid>
		<description><![CDATA[how to remove a line of code from multiple files with one script.  I have seen in more than one occasion where someone has a site with multiple files all containing the wrong code for the canonical link.  ]]></description>
			<content:encoded><![CDATA[<p>Below are instructions on how to remove a cononical link element from multiple files or any line of code from multiple files with one script.  I have seen in more than one occasion where someone has a site with multiple files all containing the wrong code for the canonical link.  </p>
<p>If you don&#8217;t know what a canonical lin tag is read about it here <a href="http://www.createbetterwebsites.com/canonical-lin-element.html">What is a canonical link tag?</a></p>
<p>Removing them from 100&#8242;s of files can be a tedious job. But not on a Mac.  On mac you can run one script that will remove a line from multiple files.  </p>
<p>The script will search for a line of code that has a common word in it.  In this case we search for a line of code that has the word canonical in it.  You have to be careful if you use this script for something else.  Make sure the line you want to remove has something unique that isn&#8217;t anywhere else in your file.  </p>
<p>It&#8217;s rare in the case for canonical to be anywhere else.  Unless you are writing an article about canonical tags as I have here.  </p>
<p>One you have the script you can run it and remove the line in just a few seconds from multiple HTML files.</p>
<p>First thing you want to do is create a file in your text editor called <strong>deletecanonical.csh</strong> with the following code.</p>
<blockquote><p>
#!/bin/bash<br />
     for file in *.html; do<br />
     mv $file $file.old<br />
     sed &#8216;d/canonical/d&#8217; $file.old > $file<br />
     rm -f $file.old<br />
     done
</p></blockquote>
<p>Save the file and place in the HTML directory.  </p>
<p>Open a terminal window on your Mac and run the command to change directories to where your HTML files are.  <a href="http://guides.macrumors.com/Terminal">Learn how to use change directory command here.</a><br />
If HTML files are in a <strong>/documents/websites</strong> then run the command <strong> &#8220;cd /documents/websites&#8221;</strong><br />
The file you created for the script file should be in this directory along with all the HTML files in which you want to remove the canonical tag.</p>
<p>Next you need to run the following command to make your file executable.</p>
<blockquote><p>chmod a+x deletecanonical.csh</p></blockquote>
<p>Then just run the file in the terminal like this.</p>
<blockquote><p>./deletecanonical.csh</p></blockquote>
<p>Voila &#8230;.<br />
All .html files that had a line of code with the word canonical have been removed.  You can apply this to any line of code you want to delete.  Just be very careful.  You may want to back up your files just in case you make a mistake.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/how-to-remove-canonical-links.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Highlight Text on a Website</title>
		<link>http://www.createbetterwebsites.com/how-to-highlight-text-on-a-website.html</link>
		<comments>http://www.createbetterwebsites.com/how-to-highlight-text-on-a-website.html#comments</comments>
		<pubDate>Sun, 01 Aug 2010 18:22:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[highlight text]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=603</guid>
		<description><![CDATA[How to Highlight Text on a Website using CSS and inline styling.]]></description>
			<content:encoded><![CDATA[<p>If you want to know how to highlight text on your website using CSS like this for example. <span style="background-color: yellow;">This is a highlighted text area.</span></p>
<p>The HTML code can be any type of tag.  But the example above I&#8217;m using span tag like this.  The <span> tag provides no visual change by itself. The <span> tag is just a way to add a style to a part of a text or a part of a document&#8217;s content with no other styling.  If I use div in the above example then the highlighted text would also have a line break which I don&#8217;t want in this case.</span></span></p>
<p><span id="orange-highlight" style="background-color: #ff9f2f;">This text is highlighted in orange. </span><span id="greenhighlight" style="background-color: #67ff5f;">This text is highlighted in light green. </span> <span id="yellowhighlight" style="background-color: #fff15f;">This text is highlighted in bright yellow.</span></p>
<p>You can do this by adding inline styling, which means the style is in the HTML Document.  See the code below.</p>
<blockquote><p>&lt;span id=&#8221;orange-highlight&#8221; style=&#8221;background-color: #ff9f2f;&#8221;&gt;This text is highlighted in orange.  &lt;/span&gt;&lt;span id=&#8221;green-highlight&#8221; style=&#8221;background-color: #67ff5f;&#8221;&gt;This text is highlighted in light green. &lt;/span&gt; &lt;span id=&#8221;yellow-highlight&#8221; style=&#8221;background-color: #fff15f;&#8221;&gt;This text is highlighted in bright yellow.&lt;/span&gt;</p></blockquote>
<p>Or strip out all the style elements and put them in a stylesheet.  So you&#8217;re stylesheet would look like below.  And in the HTML then you will have only the &lt;span id=&#8221;green-highlight&#8221;&gt; and so on.</p>
<blockquote><p>#green-highlight {<br />
background-color: #67ff5f;<br />
}<br />
#yellow-highlight {<br />
background-color: #fff15f;<br />
}<br />
#orange-highlight {<br />
background-color: #ff9f2f;<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/how-to-highlight-text-on-a-website.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Translate Webpage Content</title>
		<link>http://www.createbetterwebsites.com/how-to-translate-webpage-content.html</link>
		<comments>http://www.createbetterwebsites.com/how-to-translate-webpage-content.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 19:37:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[translate a webpage]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=585</guid>
		<description><![CDATA[How to Translate Webpage Content into multiple languages using google translator tools.]]></description>
			<content:encoded><![CDATA[<p>Do you want to translate webpage content on your website to different languages?  It&#8217;s a great idea to offer translation if your site caters to international visitors.</p>
<p>There is one very easy and simple way to do this using Google translate on your website.  Visit the <a href="http://translate.google.com/translate_tools">google translate</a> site and follow the instructions.</p>
<p>You can choose all languages or specific languages if you like.  For example if I want to translate webpage to only Russian then in the Google translate tool I choose specific languages and then just select Russian and English.  Always add English as well.  This way your user&#8217;s can go back to English as well.</p>
<p>It gives me the following code to copy and past on to translate this webpage to Russian.</p>
<blockquote><p>
&lt;div id=&#8221;google_translate_element&#8221;&gt;&lt;/div&gt;&lt;script&gt;<br />
function googleTranslateElementInit() {<br />
new google.translate.TranslateElement({<br />
pageLanguage: &#8216;en&#8217;,<br />
includedLanguages: &#8216;en,ru&#8217;<br />
}, &#8216;google_translate_element&#8217;);<br />
}<br />
&lt;/script&gt;&lt;script src=&#8221;http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit&#8221;&gt;&lt;/script&gt;
</p></blockquote>
<p>And this is how it looks on your website.  You can place it anywhere of course.  Try it out and see how it works.</p>
<div id="google_translate_element"></div>
<p><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    includedLanguages: 'en,ru'
  }, 'google_translate_element');
}
</script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></p>
<p>On this <a href="http://www.strongshape.com">Strength Training</a> site for example, you&#8217;ll see it on the top right column for every language.  So user&#8217;s can translate all pages to any language.</p>
<p>NOTE: On this particular webpage the code above gets translated as well.  Which I don&#8217;t want.  But I don&#8217;t know how to avoid that.  So if you are translating this and want to copy the code from here make sure you go back to English first then copy the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/how-to-translate-webpage-content.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS DIV Code Instead of Tables</title>
		<link>http://www.createbetterwebsites.com/css-div-code-instead-of-tables.html</link>
		<comments>http://www.createbetterwebsites.com/css-div-code-instead-of-tables.html#comments</comments>
		<pubDate>Mon, 26 Jul 2010 18:10:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css div code]]></category>
		<category><![CDATA[css divs]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=524</guid>
		<description><![CDATA[It&#8217;s always better to use CSS div code instead of tables for layout items in HTML. Use tables only if you have tabular data and lots of it. But if for example you just want to display a 1 row, two column item on your pages use div&#8217;s. Here&#8217;s a n example. This is the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s always better to use CSS div code instead of tables for layout items in HTML.  Use tables only if you have tabular data and lots of it.  But if for example you just want to display a 1 row, two column item on your pages use div&#8217;s.</p>
<p>Here&#8217;s a n example.</p>
<div style="width: 48%;  float: left; font-weight: bold; padding: 10px  0 10px 0;">This is the first column.  I can put anything in here.</div>
<div style="width: 48%; float: right; font-weight: bold; padding: 10px  0 10px 0;">This is the second column and again I can insert anything in place of this text.</div>
<p></p>
<div style="clear:both;">
The rest of your content goes here below the two columns.  This part needs to be styled to clear: both.  See the code below for this.
</div>
<p>Here&#8217;s the HTML Code for the above example:</p>
<blockquote><p>
&lt;div id=&#8221;col1&#8243;&gt;This is the first column.  I can put anything in here.&lt;/div&gt;<br />
&lt;div id=&#8221;col2&#8243;&gt;This is the second column and again I can insert anything in place of this text.&lt;/div&gt;<br />
&lt;div id=&#8221;content-below&#8221;&gt;</p>
<p>This is the rest of the content below the columns.</p>
<p>&lt;/div&gt;
</p></blockquote>
<p>Here is the CSS code for the above;</p>
<blockquote><p>
#col1 {<br />
width: 48%;<br />
float: left;<br />
font-weight: bold;<br />
padding: 10px  0 10px 0;<br />
}<br />
#col2 {<br />
width: 48%;<br />
float: right;<br />
font-weight: bold;<br />
clear: right;<br />
padding: 10px  0 10px 0;<br />
}<br />
#content-below {<br />
clear: both<br />
}</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/css-div-code-instead-of-tables.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vertical Collapsible, Expandable Menu</title>
		<link>http://www.createbetterwebsites.com/vertical-collapsible-expandible-menu.html</link>
		<comments>http://www.createbetterwebsites.com/vertical-collapsible-expandible-menu.html#comments</comments>
		<pubDate>Tue, 25 May 2010 23:39:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[collapsible menu]]></category>
		<category><![CDATA[expandable menu]]></category>

		<guid isPermaLink="false">http://www.createbetterwebsites.com/?p=419</guid>
		<description><![CDATA[A vertical collapsible, expandable menu is a great way to organize a large site and create a much more user friendly experience.  A navigation menu is probably one of the most critical pieces in web design. ]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.createbetterwebsites.com/scripts/collapsable-menu.js" type="text/javascript"></script></p>
<link href="http://www.createbetterwebsites.com/scripts/collapsable-menu.css" rel="stylesheet" type="text/css">
A vertical collapsible, expandable menu is a great way to organize a large site and create a much more user friendly experience.  A navigation menu is probably one of the most critical pieces in web design.  So making your navigation subcats easy to find and all in one location can be a great way to help your user&#8217;s find things on your website.</p>
<p>In this article I show by example a vertical collapsible, expandable menu which is extremely easy to implement and can be great for organizing large navigation systems.</p>
<p>Start by organizing your menu subcats into categories and subcategories.</p>
<h2>Menu Example</h2>
<p>Click on the links below to expand and collapse the categories.</p>
<ul id="nav">
<li> <a id="pm1" class="span" onclick="menuexpand('m1');return false;" href="#">Category 1</a>
<ul id="m1">
<li><a href="#">subcat 1a</a></li>
<li><a href="#">subcat 1b</a></li>
<li><a href="#">subcat 1c</a></li>
<li><a href="#">subcat 1d</a></li>
</ul>
</li>
<li> <a id="pm2" class="span" onclick="menuexpand('m2');return false;" href="#">Category 2</a>
<ul id="m2">
<li><a href="#">subcat 2a</a></li>
<li><a href="#">subcat 2b</a></li>
<li><a href="#">subcat 2c</a></li>
<li><a href="#">subcat 2d</a></li>
</ul>
</li>
<li> <a id="pm3" class="span" onclick="menuexpand('m3');return false;" href="#">Category 3</a>
<ul id="m3">
<li><a href="#">subcat 3a</a></li>
<li><a href="#">subcat 3b</a></li>
<li><a href="#">subcat 3c</a></li>
<li><a href="#">subcat 3d</a></li>
</ul>
</li>
<li> <a id="pm4" class="span" onclick="menuexpand('m4');return false;" href="#">Category 4</a>
<ul id="m4">
<li><a href="#">subcat 4a</a></li>
<li><a href="#">subcat 4b</a></li>
<li><a href="#">subcat 4c</a></li>
<li><a href="#">subcat 4d</a></li>
</ul>
</li>
<li> <a id="pm5" class="span" onclick="menuexpand('m5');return false;" href="#">Category 5</a>
<ul id="m5">
<li><a href="#">subcat 5a</a></li>
<li><a href="#">subcat 5b</a></li>
<li><a href="#">subcat 5c</a></li>
<li><a href="#">subcat 5d</a></li>
</ul>
</li>
</ul>
<p>The first thing you&#8217;ll need is the Javascript code which collapses and expands the menu.</p>
<blockquote><p>var myvar;<br />
function menuinit() {<br />
document.getElementById(&#8216;m1&#8242;).style.display = &#8216;none&#8217;;<br />
document.getElementById(&#8216;m2&#8242;).style.display = &#8216;none&#8217;;<br />
document.getElementById(&#8216;m3&#8242;).style.display = &#8216;none&#8217;;<br />
document.getElementById(&#8216;m4&#8242;).style.display = &#8216;none&#8217;;<br />
document.getElementById(&#8216;m5&#8242;).style.display = &#8216;none&#8217;;</p>
<p>}<br />
function menuexpand (i) {<br />
menuinit();<br />
if (myvar == i) {<br />
document.getElementById(i).style.display = &#8216;none&#8217;;<br />
myvar = &#8221;;<br />
}<br />
else {<br />
document.getElementById(i).style.display = &#8216;block&#8217;;<br />
myvar = i;<br />
}<br />
}</p>
<p>if ( typeof window.addEventListener != &#8220;undefined&#8221; )<br />
window.addEventListener( &#8220;load&#8221;, menuinit, false );<br />
else if ( typeof window.attachEvent != &#8220;undefined&#8221; ) {<br />
window.attachEvent( &#8220;onload&#8221;, menuinit );<br />
}<br />
else {<br />
if ( window.onload != null ) {<br />
var oldOnload = window.onload;<br />
window.onload = function ( e ) {<br />
oldOnload( e );<br />
menuinit();<br />
};<br />
}<br />
else<br />
window.onload = init;<br />
}</p></blockquote>
<p>To add additional categories to this you&#8217;ll need to add to the Javascript as well.  For example to add a sixth category to this menu, simply add the following line of code to the end of the menuinit() function.</p>
<blockquote><p>document.getElementById(&#8216;m5&#8242;).style.display = &#8216;none&#8217;;</p></blockquote>
<p>You can add as many extra categories as you need this way.</p>
<h2>The HTML code</h2>
<blockquote><p>&lt;ul id=&#8221;nav&#8221;&gt;<br />
&lt;li&gt; &lt;a id=&#8221;pm1&#8243; onclick=&#8221;menuexpand(&#8216;m1&#8242;);return false;&#8221; href=&#8221;#&#8221;&gt;Category 1&lt;/a&gt;<br />
&lt;ul id=&#8221;m1&#8243;&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 1a&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 1b&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 1c&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 1d&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt; &lt;a id=&#8221;pm2&#8243; onclick=&#8221;menuexpand(&#8216;m2&#8242;);return false;&#8221; href=&#8221;#&#8221;&gt;Category 2&lt;/a&gt;<br />
&lt;ul id=&#8221;m2&#8243;&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 2a&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 2b&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 2c&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 2d&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt; &lt;a id=&#8221;pm3&#8243; onclick=&#8221;menuexpand(&#8216;m3&#8242;);return false;&#8221; href=&#8221;#&#8221;&gt;Category 3&lt;/a&gt;<br />
&lt;ul id=&#8221;m3&#8243;&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 3a&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 3b&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 3c&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 3d&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt; &lt;a id=&#8221;pm4&#8243; onclick=&#8221;menuexpand(&#8216;m4&#8242;);return false;&#8221; href=&#8221;#&#8221;&gt;Category 4&lt;/a&gt;<br />
&lt;ul id=&#8221;m4&#8243;&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 4a&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 4b&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 4c&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 4d&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt; &lt;a id=&#8221;pm5&#8243; onclick=&#8221;menuexpand(&#8216;m5&#8242;);return false;&#8221; href=&#8221;#&#8221;&gt;Category 5&lt;/a&gt;<br />
&lt;ul id=&#8221;m5&#8243;&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 5a&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 5b&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 5c&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;subcat 5d&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;/ul&gt;</p></blockquote>
<h3>Download the files</h3>
<p><a href="http://www.createbetterwebsites.com/scripts/collapsable-menu.css">The CSS File</a><br />
<a href="http://www.createbetterwebsites.com/scripts/collapsable-menu.js">The Javascript File</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.createbetterwebsites.com/vertical-collapsible-expandible-menu.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
