How to strip all the class (CSS) attributes in a HTML file in vscode?

Viewed 1545

I am creating email templates in HTML. I am using classes to style components during development. I want to strip all class attributes before shipping the final version. How to achieve it in VSCODE?

I tried selecting all occurances of the word class, but the length and number of the classes vary across the file. So this don't work.

<tr>
  <td class="cta" height="32">
    <a class="cta-inner" href="#" style="color:#fff;"></a>
      Go To Task
    </a>
  </td>
</tr>

I expect cta and cta-inner class to be removed from the resulting html.

1 Answers
  • Select class attribute and then press CTRL + F
  • Type class="[\w|\W]*?" and press replace all
  • Check the image below for more details

enter image description here

Related