You could make it a lot easier on yourself with a few structure changes. I'd suggest removing the "gallery2" element, and putting those last two rows directly in the "gallery" element. It should be like this (With your code in the 'list items'):
Code:
<div id="gallery">
<ul>
<li> Link / Photo </li>
<li> Link / Photo </li>
<li> Link / Photo </li>
</ul>
<ul>
<li> Link / Photo </li>
<li> Link / Photo </li>
<li> Link / Photo </li>
</ul>
<ul>
<li> Link / Photo </li>
<li> Link / Photo </li>
<li> Link / Photo </li>
</ul>
<ul>
<li> Link / Photo </li>
<li> Link / Photo </li>
<li> Link / Photo </li>
</ul>
</div>
You may want to change the structuring CSS to something like this:
#gallery { padding: 25px 0px; }
By the looks of the page you would want the images themselves to be aligning to the left side of that column, zeroing the left/right padding would help.
#gallery ul li { margin-left: 20px; }
The distance between images can be set like this, it's a bit more specific than simply li { margin: ect; }.
It's good practice to not override the default elements' style for a sub-project, in-case you want to use it later elsewhere.
#gallery ul:first-child { margin-left: 0px; }
To eliminate the "spacer" for the first images in each row. For our purposes a 'ul' element essentially equals a row.
That should pretty much be all you need, when used with your existing code!
Edit: Actually, it might be:
#gallery ul li:first-child { margin-left: 0px; }. I tell you this all works fine in my head! Famous last words.