<?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>Garrick Cheung &#187; HTML / XHTML</title>
	<atom:link href="http://www.garrickcheung.com/category/html_xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garrickcheung.com</link>
	<description>Sharing what I know and learn about CSS, MooTools, Javascript, PHP and etc.</description>
	<lastBuildDate>Wed, 28 Apr 2010 02:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>CSS Best Practice #3: Clear Floated Containers (with Height&#124;&#124;Width and Overflow)</title>
		<link>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 01:00:21 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[clear float]]></category>
		<category><![CDATA[hasLayout]]></category>
		<category><![CDATA[overflow]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=217</guid>
		<description><![CDATA[I know you&#8217;ve done it before. I think we&#8217;ve all done it. You have a container with a floated element inside. The container doesn&#8217;t wrap around everything, thus causing the element to break outside of the container. To fix this, we&#8217;d usually add a clear element at the bottom of the container so it would [...]]]></description>
			<content:encoded><![CDATA[<p>I know you&#8217;ve done it before. I think we&#8217;ve all done it. You have a container with a floated element inside. The container doesn&#8217;t wrap around everything, thus causing the element to break outside of the container. To fix this, we&#8217;d usually add a clear element at the bottom of the container so it would wrap everything within. But there is a better solution, which uses two CSS properties. For this example, I&#8217;ll place the styles inline.. please don&#8217;t hate me.<span id="more-217"></span></p>
<p><strong>If you want to just get to the <a href="#solution">better solution&#8230;</a></strong></p>
<h3>The Example</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Proceeding with the example, div.clear is placed at the bottom of div.container, which solves the problem. Div.container&#8217;s border now wraps all the elements within.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
    &lt;div class=&quot;clear&quot; style=&quot;clear:both;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3><a name="solution"></a>The Better Solution</h3>
<p>But why should we even bother placing an extra element? It&#8217;s not sexy. Here&#8217;s the solution: Use height:1% or width:100% and overflow:auto||hidden on div.container. Height and width on div.container would set the hasLayout property in IE, thus fixing a slew of float/box-model bugs (<a href="http://www.satzansatz.de/cssd/onhavinglayout.html" target="_blank">more on hasLayout</a>). Overflow auto or hidden tells div.container to wrap everything within it.</p>
<p><strong>Note:</strong> This won&#8217;t work if the element is floated, which would cause it to shrink to the percentage height or width.</p>
<p>The HTML</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>The CSS</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">1</span>%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Solution to Flash and Select Drop-downs Covering HTML Elements</title>
		<link>http://www.garrickcheung.com/javascript/solution-to-flash-and-select-drop-downs-covering-html-elements/</link>
		<comments>http://www.garrickcheung.com/javascript/solution-to-flash-and-select-drop-downs-covering-html-elements/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 13:00:15 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[markup hierarchy]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=91</guid>
		<description><![CDATA[I&#8217;ve positioned elements absolutely and had to deal with a bug where the element appears below a flash object or select drop-downs, which usually occurs in IE. I&#8217;ve seen a few solutions, which work great, and I have one more to add. Solution 1: iFrame This solution comes from Joe King&#8217;s post. In case you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve positioned elements absolutely and had to deal with a bug where the element appears below a flash object or select drop-downs, which usually occurs in IE. I&#8217;ve seen a few solutions, which work great, and I have one more to add.<span id="more-91"></span></p>
<h3>Solution 1: iFrame</h3>
<p>This solution comes from <a href="http://www.dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx" target="_blank">Joe King&#8217;s post</a>.</p>
<blockquote><p>In case you don&#8217;t already know, windowed controls in IE will always cover DHTML layers.  That means if you have a DIV that pops up or floats on the page and it intersects with a windowed control (such as the common SELECT box), the windowed control will obscure the DIV, no matter what zIndex you have set for each element.</p></blockquote>
<p>The solution is to create an iFrame shim under the element that needs to appear above the select drop down.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id_of_element'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> iframe_shim <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Element<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iframe'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">'id'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'shim'</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'scrolling'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'no'</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'frameborder'</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'styles'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'width'</span><span style="color: #339933;">:</span> element.<span style="color: #660066;">getSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">x</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//Plug in the width of absolutely positioned object here</span>
        <span style="color: #3366CC;">'height'</span><span style="color: #339933;">:</span> element.<span style="color: #660066;">getSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">y</span><span style="color: #339933;">;,</span> <span style="color: #006600; font-style: italic;">//Plug in the height of absolutely positioned object here</span>
        <span style="color: #3366CC;">'filter'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'</span> <span style="color: #006600; font-style: italic;">// fixes transparency</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">inject</span><span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span><span style="color: #3366CC;">'after'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//this automatically injects the shim after the element.</span></pre></td></tr></table></div>

<p>Keep in mind you&#8217;ll probably need to modify this to work with your needs. E.g. For drop down navigation, you would create the shim and use Javascript to make adjustments to the position and dimensions of the shim to reflect that dropped down menu in the navigation.</p>
<h3>Solution 2: Flash Param: wmode=transparent</h3>
<p>This solution was found on <a href="http://www.cssplay.co.uk/menus/flyout_flash.html" target="_blank">CSS Play by Stu and Fran Nicholls</a>.</p>
<p>So you have a flash object and you require HTML elements to appear above it. You set the HTML elements positioning to absolute and try z-index, which probably didn&#8217;t work in IE. You only need to set the flash object&#8217;s wmode parameter to transparent to fix this. Use the &lt;param&gt; to set the name/value, and set the wmode attribute on the &lt;embed&gt; tag like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;
&lt;embed src=&quot;flash.swf&quot; quality=&quot;high&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;100&quot; height=&quot;100&quot; wmode=&quot;transparent&quot;&gt;&lt;/embed&gt;</pre></td></tr></table></div>

<h3>Solution 3: Markup Hierarchy</h3>
<p>Let&#8217;s say you have a flash object that you have no control over, such as a YouTube video. The flash object comes in with wmode=&#8221;window&#8221; or something. What do you do? Consider markup hierarchy. In IE, the next HTML element is considered at a higher layer than the element before it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;box_1&quot;&gt;Box 1&lt;/div&gt;
&lt;div class=&quot;box_2&quot;&gt;Box 2&lt;/div&gt;</pre></td></tr></table></div>

<p>Box 1 will appear above Box 2. So using the drop down navigation as an example again (from solution 1) I would use Javascript to relocate the navigation&#8217;s html markup below the flash object and adjust the positioning of the nav to make it look like it never moved via CSS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/solution-to-flash-and-select-drop-downs-covering-html-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dustin Diaz on DocTypes</title>
		<link>http://www.garrickcheung.com/html_xhtml/dustin-diaz-on-doctypes/</link>
		<comments>http://www.garrickcheung.com/html_xhtml/dustin-diaz-on-doctypes/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 09:20:41 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[doctype]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=187</guid>
		<description><![CDATA[I just had to share this one with you as soon as I read it. Dustin Diaz shows us a way of declaring a doctype, that puts the browser is standards mode. Thought it won&#8217;t validate, which he explains: There is really, absolutely no reason you need the rest of the doctype in your declaration [...]]]></description>
			<content:encoded><![CDATA[<p>I just had to share this one with you as soon as I read it. <a href="http://www.dustindiaz.com/skinny-on-doctypes/" target="_blank">Dustin Diaz shows us a way of declaring a doctype</a>, that puts the browser is standards mode. Thought it won&#8217;t validate, which he explains:</p>
<blockquote><p>There is really, absolutely no reason you need the rest of the doctype in your declaration unless you’re validating code. Furthermore, it does not mean that your page is even invalid. In the end, it puts your webpages into standards mode, which is what really matters.</p></blockquote>
<p><span id="more-187"></span></p>
<h3>The Code</h3>
<p>It&#8217;s so simple! Just brilliant. Here it is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!doctype html&gt;</pre></td></tr></table></div>

<p>You should just&#8230;</p>
<blockquote><p>Try it out. It will fix your box model in IE6 and clobber all those other funny gotchas when you’re in quirks mode.</p></blockquote>
<p>I&#8217;ll be sure to keep this one in mind. Thank you, Dustin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/html_xhtml/dustin-diaz-on-doctypes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get Around Form submit() Mapping</title>
		<link>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/</link>
		<comments>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 06:32:27 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[submit()]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=131</guid>
		<description><![CDATA[If you&#8217;ve had to use javascript to submit a form, you may have used the forms submit() method. You may also experienced difficulty, such as a &#8220;submit is not a function&#8221; error. It has to deal with mapping and I&#8217;ve got a very simple solution. The Setup: Just so you know, this is done with [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve had to use javascript to submit a form, you may have used the forms submit() method. You may also experienced difficulty, such as a &#8220;submit is not a function&#8221; error. It has to deal with mapping and I&#8217;ve got a very simple solution.<span id="more-131"></span></p>
<h3>The Setup:</h3>
<p>Just so you know, this is done with MooTools 1.2, but if you know javascript, you can build it from scratch.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;response_form&quot; action=&quot;response.html&quot; method=&quot;get&quot;&gt;
    &lt;fieldset&gt;
        &lt;legend&gt;Test&lt;/legend&gt;
        Grab the response.
        &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot; /&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> form <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'response_form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
form.<span style="color: #660066;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=submit]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    e.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    form.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h3>The Test:</h3>
<p>Copy the code into a test html file. Open Firebug (you DO have Firebug and FireFox, don&#8217;t you?) and display the console. Click on the submit button and there should be an error.</p>
<h3>The Solution:</h3>
<p>Very simple now. Change the name to anything besides submit and you&#8217;ve fixed the mapping issue.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;submit&quot; name=&quot;submit_btn&quot; value=&quot;submit&quot; /&gt;</pre></td></tr></table></div>

<p>This one took me a while to find, but I was glad when I did. I hope this is helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Two columns with unordered lists</title>
		<link>http://www.garrickcheung.com/css/two-columns-with-unordered-lists/</link>
		<comments>http://www.garrickcheung.com/css/two-columns-with-unordered-lists/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 11:19:54 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[get_categories]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=48</guid>
		<description><![CDATA[David Walsh recently posted &#8220;Get WordPress Post Categories&#8220;, where he talked about using the wordpress get_categories() function to create a two column list of his categories in his theme. I offer a slightly different approach using an unordered list. Here&#8217;s the code: 1 2 3 4 5 6 7 8 9 10 11 12 13 [...]]]></description>
			<content:encoded><![CDATA[<p>David Walsh recently posted &#8220;<a href="http://davidwalsh.name/php-wordpress-post-categories" target="_blank">Get WordPress Post Categories</a>&#8220;, where he talked about using the wordpress get_categories() function to create a two column list of his categories in his theme.</p>
<p>I offer a slightly different approach using an unordered list.<span id="more-48"></span> Here&#8217;s the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #666666; font-style: italic;">/* BUILD THE CATEGORY LIST */</span>  
    <span style="color: #000088;">$categories</span> <span style="color: #339933;">=</span> get_categories<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'child_of'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'hide_empty'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
    <span style="color: #000088;">$category_count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$category_col</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>  
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$catty</span><span style="color: #009900;">&#41;</span>   
    <span style="color: #009900;">&#123;</span>  
        <span style="color: #000088;">$category_count</span><span style="color: #339933;">++;</span>  
        $<span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'category_list_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$category_col</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$catty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_name</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$catty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category_nicename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_count</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$category_col</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>  
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//merge the two lists -Garrick</span>
    <span style="color: #000088;">$category_list</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_list_1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$category_list_2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class=&quot;list_wrap&quot;&gt;
    &lt;ul class=&quot;category_list&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_list</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;/sugar/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ul&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Notice that the difference is the array_merge() and unordered list.</p>
<p>Now, it wouldn&#8217;t be complete with CSS, which would be something like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.list_wrap</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.category_list</span> <span style="color: #00AA00;">&#123;</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;">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;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</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: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.category_list</span> li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</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: #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;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">195px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The .list_wrap style is a container so we can do a negative margin to shift things over. The ul and li both float left so that it won&#8217;t have extra spacing that IE6 automatically adds. The li has a display:inline because it fixes the 3-pixel-bug in IE6 when an element is floated and has margin-left/right. Lastly, we have to adjust the li&#8217;s width accordingly.</p>
<p>When doing the math, you&#8217;ll notice that the li&#8217;s width and margin-left x 2 columns = 410px. Now remember that .list_wrap has a margin-left:-10px so it fixes the additional 10px from the li&#8217;s.</p>
<p><a href="http://www.garrickcheung.com/examples/two-columns-with-unordered-lists.html" target="_blank" rel="nofollow">Check out the example page</a> to get a better idea. The category list is contained in a box with borders to help you see it better.</p>
<p>I think using an unordered list makes semantic sense because, after all, you&#8217;re listing links.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/two-columns-with-unordered-lists/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
