Balance
A well-known tag balancing: searches for tag or tag's content bounds from current caret position and selects it. It will expand (outward balancing) or shrink (inward balancing) selection when called multiple times. Not every editor supports both inward and outward balancing due of some implementation issues, most editors have outward balancing only.
Emmet’s tag balancing is quite unique. Unlike other implementation, this one will search tag bounds from caret’s position, not the start of the document. It means you can use tag balancer even in non-HTML documents.
Note that tag matching may not work outside HTML if tag definition is assembled by concatenating strings, like this: var cell = '<td class="' + (data.odd ? 'odd' : 'even') + '">'
;