See the question and my original answer on StackOverflow

Here is some sample code that can truncate the inner text. It uses the recursive capability of the InnerText property and CloneNode method.

    public static HtmlNode TruncateInnerText(HtmlNode node, int length)
        if (node == null)
            throw new ArgumentNullException("node");

        // nothing to do?
        if (node.InnerText.Length < length)
            return node;

        HtmlNode clone = node.CloneNode(false);
        TruncateInnerText(node, clone, clone, length);
        return clone;

    private static void TruncateInnerText(HtmlNode source, HtmlNode root, HtmlNode current, int length)
        HtmlNode childClone;
        foreach (HtmlNode child in source.ChildNodes)
            // is expected size is ok?
            int expectedSize = child.InnerText.Length + root.InnerText.Length;
            if (expectedSize <= length)
                // yes, just clone the whole hierarchy
                childClone = child.CloneNode(true);

            // is it a text node? then crop it
            HtmlTextNode text = child as HtmlTextNode;
            if (text != null)
                int remove = expectedSize - length;
                childClone = root.OwnerDocument.CreateTextNode(text.InnerText.Substring(0, text.InnerText.Length - remove));

            // it's not a text node, shallow clone and dive in
            childClone = child.CloneNode(false);
            TruncateInnerText(child, root, childClone, length);

And a sample C# console app that will scrap this question as an example, and truncate it to 500 characters.

  class Program
      static void Main(string[] args)
          var web = new HtmlWeb();
          var doc = web.Load("");
          var post = doc.DocumentNode.SelectSingleNode("//td[@class='postcell']//div[@class='post-text']");
          var truncated = TruncateInnerText(post, 500);
          Console.WriteLine("Size: " + truncated.InnerText.Length);

When ran it, it should display this:

<div class="post-text" itemprop="text">

<p>Mainly when we shorten/truncate textual content we usually just truncate it at specific character index. That's already complicated in HTML anyway, but I want to truncate my HTML content (generated using content-editable <code>div</code>) using different measures:</p>

<li>I would define character index <code>N</code> that will serve as truncating startpoint <em>limit</em></li>
<li>Algorithm will check whether content is at least <code>N</code> characters long (text only; not counting tags); if it's not it will just return the whole content</li>
<li>It would then</li></ol></div>
Size: 500

Note: I have not truncated at word boundary, just at character boundary, and no, it's not at all following the suggestions in my comment :-)