Stored Query to Remove CSS Comments

The comments in the CSS layouts that come with Dreamweaver CS3 are deliberately verbose—they’re there to help you understand what each rule is for. Although commenting style sheets is a good idea, you’ll probably want to get rid of the Dreamweaver comments once you’re familiar with the layouts. This stored query can be loaded into the Dreamweaver Find & Replace dialog box to remove all or some of the comments quickly and cleanly.

The query has been updated to remove the longer comments in the style sheets for the liquid, hybrid, and elastic layouts.

Download stored query to remove CSS comments

Note: Safari on Mac OS X automatically adds an .xml filename extension to the stored query file when you download it. After downloading, select the file in Finder and press Cmd-I to open the Get Info panel. Remove the .xml filename extension, and deselect the check box to hide the extension. The file must have a .dwr filename extension for it to be recognized by Dreamweaver.

Instructions for use

  1. Open the style sheet in the Document window. If the styles are embedded in the <head> of the document, switch to Code view.
  2. Launch Find & Replace from the Edit menu (or press Ctrl+F/Cmd+F).
  3. Find and replace iconsClick the Load Query icon at the top right of the Find and Replace dialog box. It looks like a folder with a document sticking out of it.
  4. In the Load Query dialog box, select css_comment_remover_v3.dwr, and click Open. This loads the query into the Find and Replace dialog box and sets all the necessary options.
  5. To remove all the CSS comments in a single operation, click Replace All. This removes all comments, including any CSS hacks that look like comments. If you’re in any way uncertain, use the following more selective approach.

    To remove comments selectively, click Find Next to highlight the first one. Click Replace to remove it or Find Next to move to the next one.

Dreamweaver always remembers your last find and replace operation, so these settings will be displayed the next time you open the Find & Replace panel. Delete the regular expression from the Find field and deselect the Use regular expression check box (unless you plan to use another regex). This final point is very important. When a find operation fails for no obvious reason, it’s usually because you have selected the Use regular expression check box by accident.

Other Dreamweaver Extensions

Lorem and More

Convert to RGBA


Books & Videos by David Powers

Introducing PHP

Up & Running with phpMyAdmin

Responsive Design with Bootstrap and Dreamweaver CC 2015

PHP Solutions, Third Edition

PHP for Web Designers

Beginning CSS3

Dreamweaver CS6: Learn by Video

Adobe Dreamweaver CS5 with PHP: Training from the Source

PHP Object-Oriented Solutions

Books & Videos by David Powers

PHP SolutionsBeginning CSS3Dreamweaver CS6: Learn by VideoDreamweaver CS5.5: Learn by VideoDreamweaver CS5.5 for MobileDreamweaver CS5 with PHP