How-To Use Valid XHTML Tags in TextMate
Here's a tip I just now found out about. In TextMate, the HTML bundle has a ton of available snippets. Unfortunately, they don't automatically add the closing trailing slash for certain elements. For example, instead of inserting
<br/> or <input type="text"/>
TextMate inserts
<br> or <input type="text">
(Note the missing trailing slashes.)
You can change this behavior by going to
- TextMate Preferences → Advaned → Shell Variables
- Create a new variable called "TM_XHTML" with value "/" (no quotes)
Now TextMate will output valid XHTML when you use the HTML bundle. Here's a screenshot showing the correct setup. Hope this helps!

Great tip, thanks :) I might recommend adding a space before the slash in the value field, as the XHTML spec indicates that this is necessary; so becomes
Tom Bates
04/14/08
02:48 am
mike, this isn't set by default because, for reasons I can't explain, there are people out there still using HTML. Thanks for this tip. TextMate's built-in validator is much happier now :-)
luke hartman
02/26/08
12:01 am
... and why isn't this set by default?
mike
12/21/07
03:32 pm
is that all? i'm new about mac and textmate and i was just wondering why it doesnt close single tags! i don't really know what i've just done but seems works! thanks!
Pix
08/03/07
08:48 am
Oh, for cryin' out loud... THAT'S how you do it. The missing slash has been driving me nuts!
erat
04/27/07
04:13 pm
[...] How-To Use Valid XHTML Tags in TextMate [...]
Nashville is Talking » Knick Knacks
03/27/07
05:32 pm