Zen HTML and CSS coding, and how to install it on Windows with E Text-Editor

by Cedric Dugas on November 24, 2009

Zen coding is one of the new cool kid presently, if you haven’t heard of it I would suggest your read this article from smashing magazine or look at this video presentation.

Basically it enables you to create HTML from CSS snippet. It might not sound powerful at first, but when you start playing with, some wonderful things happen in your head (with no drugs). Let’s look at a simple example, let’s say you want a header with an id and a class followed by a list element. Here what you would do with zen:

div#header.home>ul>li*3

You do Apple-E (CTRL-E in win) and you get:

  <div id="header" class="home">
  	<ul>
  		<li></li>
  		<li></li>
  		<li></li>
  	</ul>
  </div>

There is much more about Zen, but this is the basic idea. Personally it replaced my basic HTML and CSS bundle. Now if you are on Windows, you are a bit out of luck, beside some IDE Zen is not available, however there is a Textmate bundle for it. Introducing you to E Text-editor, a port from Textmate on Windows. E is a pretty amazing text editor, and if you know nothing about bundle and textmate, I would suggest do a bit of research with Google. You can also get a free trial on the website.

A small problem with Zen, there is “illegal” characters in the HTML bundle, something Windows really doesn’t like. I however successfully extracted the bundle with 7zip, it’s not going to work with you basic winrar or winzip.

Cool, you got all your bundles now, you could put them in the bundle E folder, but this is not recommended, as reinstalling E will cause an erase of your bundles, it is better to put them in the application directory, usually something like “C:\Documents and Settings\[username]\Application Data\e”

Last thing! One problem you might get is that there is no self closing XHTML “/” with your tag, this is a variable you need to put in your settings -> Environnment : TM_XHTML /

Have fun and be Zen!



6 comments

This isn’t as cool as it looks … also most IDE’s like Aptana Studio, has very well written auto complete features, that makes this just needless and pointless.

The syntax is interesting, but nevertheless it has to be learned and mastered before it could help me .. or anyone else to.

by Martin Chaov on November 25, 2009 at 7:13 am. Reply #

Hey Martin,

Well I suppose this isn’t for everyone, I personally use E because of the textmate bundle that I find very powerful, the syntax highlighting and well because it is very light.

That said, I do a lot of HTML templating and this really improved my speed, even if you do not use the complete functionality, doing div#header.clearfix is a faster way of working, for me anyway.

by Cedric Dugas on November 25, 2009 at 8:46 am. Reply #

Zen looks awesome to someone who’s worked with CSS for years, it makes complete sense.. It’s annoying that it isn’t available for Visual Studio already!!

Dreamweaver/Vis Studio have great autocomplete features.. I particularly like how in VS if you copy/paste from say it will duplicate the empty tag and put in all the white space for you..

To me it looks useful for those times where you are creating content pages at speed from say a word document where you need to bang out sentences, lists, tables of data etc.. at speed.. I currently flesh out the complete structure of a content page and then copy and paste each paragraph or whatever in between the tags.. This would mean I could code content and paste at the same time..

Bring it on.. Someone make a Visual studio config file or something!!

by Mark Henderson on November 30, 2009 at 10:45 am. Reply #

If you’re on Mac, it’s bundle in Espresso. ” Ctrl + , ” to activate it.

by Benoit Deziel on December 4, 2009 at 11:54 am. Reply #

Articles like these put the consumer in the driver seat-very ipmaortnt.

by Ollie on September 5, 2011 at 8:15 am. Reply #

@Mark: There is a Visual Studio addin already available at: http://tech.einaregilsson.com/2009/11/12/zen-coding-visual-studio-addin/

by Einar on December 5, 2009 at 1:17 am. Reply #

Leave your comment

Required.

Required. Not published.

If you have one.