function getRangeForHTMLItem(tag, offset, selRange, isBackward) {
						var ranges = makePossibleRangesHTML(tag, xmlParser.parse(tag), offset);

						if (isBackward)
							ranges.reverse();

						// try to find selected range
						var curRange = utils.find(ranges, function (r) {
							return r.equal(selRange);
						});

						if (curRange) {
							var ix = ranges.indexOf(curRange);
							if (ix < ranges.length - 1)
								return ranges[ix + 1];

							return null;
						}

						// no selected range, find nearest one
						if (isBackward)
							// search backward
							return utils.find(ranges, function (r) {
								return r.start < selRange.start;
							});

						// search forward
						// to deal with overlapping ranges (like full attribute definition
						// and attribute value) let's find range under caret first
						if (!curRange) {
							var matchedRanges = ranges.filter(function (r) {
								return r.inside(selRange.end);
							});

							if (matchedRanges.length > 1)
								return matchedRanges[1];
						}


						return utils.find(ranges, function (r) {
							return r.end > selRange.end;
						});
					}
Returns best HTML tag range match for current selection
@param {String} tag Tag declaration
@param {Number} offset Tag's position index inside content
@param {Range} selRange Selection range
@return {Range} Returns range if next item was found, <code>null</code> otherwise