Write HTML and CSS quicker with with Zen Coding

A pretty neat plugin for TextMate (and a few other text editors) that I have started using is Zen Coding. I’d heard of it before but didn’t “get it” until I read Jonathan Christopher’s blog post The Art of zen-coding: Bringing Snippets to a New Level.

Jonathan explains very well what you can do with Zen Coding, so I’m not going to get into much detail. One example though. Zen Coding lets you use syntax that looks very much like CSS selectors to write HTML, which can look like this:

div#news.module>div.header+div.body>ul>li#item-$*5

When you put the cursor at the end of that line and execute the Zen Coding command, the result will be the following HTML snippet:

<div id="news" class="module">
	<div class="header"></div>
	<div class="body">
		<ul>
		<li id="item-1"></li>
		<li id="item-2"></li>
		<li id="item-3"></li>
		<li id="item-4"></li>
		<li id="item-5"></li>
		</ul>
	</div>
</div>

This is just one quick example of what Zen Coding can do. Try it out for yourself.

Posted on September 21, 2009 in Coding, Productivity