简体   繁体   English

如何在vscode中去除HTML文件中的所有class(CSS)属性?

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

I am creating email templates in HTML.我在 HTML 中创建 email 模板。 I am using classes to style components during development.我在开发过程中使用类来设置组件的样式。 I want to strip all class attributes before shipping the final version.我想在发布最终版本之前删除所有class属性。 How to achieve it in VSCODE?如何在 VSCODE 中实现?

I tried selecting all occurances of the word class , but the length and number of the classes vary across the file.我尝试选择单词class的所有出现,但类的长度和数量因文件而异。 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.我希望从生成的 html 中删除ctacta-inner class。

  • Select class attribute and then press CTRL + F Select class 属性然后按 CTRL + F
  • Type class="[\w|\W]*?"键入class="[\w|\W]*?" and press replace all然后按全部替换
  • Check the image below for more details查看下面的图片了解更多详情

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM