[!--quoteo(post=377747:date=May 28 2006, 06:34 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 28 2006, 06:34 AM) [snapback]377747[/snapback][/div][div class=\'quotemain\'][!--quotec--] An easier solution, maybe... Try to remove ALL the tabs and whitespaces (something like an extended ltrim()) and THEN add tabs. Obviously everything would be "tabbed" automatically and by the same number of tabs, but creating some script that can detect and understand nested tags is not something I am willing, and maybe capable of doing for now. [/quote] Yes, that is what I am using now, but I'm looking for the complex version. I should've noted in my post: only XHTML strict will be used for the tabbing, so any HTML tags ending in [b]/>[/b] can be ignored for nesting.