To read the article online, visit

Stripping HTML Tags

By Abd Shomad

Note from Scott Mitchell, webmaster:
Ah, it's nice to see an article by Abd. It's been too long since his last article! This nifty little script will strip all the HTML tags from out of a string.

Here's a way to Strip HTML Tags. I found this snippet of code is very usefull when you want to output either HTML or PLAIN TEXT with your ASPMail/CDONTS component. (To learn more about sending emails through an ASP page, be sure to read the Email FAQ Category section at!)

Here's the code:

' Function Strip All HTML Tags ' Author Abd Shomad: ' Function StripHTMLTag(ByVal sText) StripHTMLTag = "" fFound = False Do While InStr(sText, "<") fFound = True StripHTMLTag = StripHTMLTag & " " & Left(sText, InStr(sText, "<")-1) sText = MID(sText, InStr(sText, ">") + 1) Loop StripHTMLTag = StripHTMLTag & sText If Not fFound Then StripHTMLTag = sText End Function

For this to work, your HTML tags must be VALID HTML tags! If you have any < or >, that do not denote the beginning of an HTML tag, you need to repalce < with &lt; and > with &gt; (for example, if you have in your HTML string: "The following is a true statement: 5 < 10", you would need to replace the < with &lt;.)

A More Updated Version
The above function is a bit buggy and picky, requiring a matching number of < and > signs. A cleaner and more flexible HTML stripping function can be found at: Stripping HTML Tags Using Regular Expressions.

Happy Programming!


  • The source code for the StripHTMLTag in text format

  • Article Information
    Article Title: Stripping HTML Tags
    Article Author: Abd Shomad
    Published Date: Friday, October 01, 1999
    Article URL:

    Copyright 2018 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers