Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any tool to show you all elements/pages in a site that are affected by a particular CSS rule?

Tags:

html

css

Of course we can use tools like Firebug to highlight portions of HTML and see what all CSS is being applied.

But what about the reverse? Is there some kind of tool which would allow you to highlight a particular CSS rule and show you all the pages on a site (either static HTML pages or their dynamic templates) that it applies to?

Example: I've come to work on a new site, very large and I need to edit CSS on a particular page but in doing so, I have no idea how many other pages on the site might also have these class names and hence be affected. Of course I can try to search the whole site for the class name(s) but this can be time consuming or tricky. This site has a class named "ba" for example. Guess how many irrelevant pages will turn up if I just search for "ba"? So how about including a double quote ("ba)? Well, it could be in the middle of a few other classes (class="hz ba top"), at the end (class="hz ba"), etc. More so, it could be dynamically plugged in via server side code making it even harder to find. A tool that could somehow spider your site and be able to identify all the places your CSS change will affect would be great.

like image 740
Doug Avatar asked Jan 30 '10 21:01

Doug


People also ask

How do you select all elements in CSS?

The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").

What is a style rule?

Style rules determine the styles applied to elements in a document. Each style rule comprises of a selector and a declaration.

Which selects all the p elements on the page?

CSS selector is selecting all p elements in page.

How do you select an element in a class in CSS?

To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class. To do this, start with the element name, then write the period (.)


2 Answers

not exactly that, but there is a firebug plugin that does that for any loaded page:

http://robertnyman.com/firefinder/

like image 95
Mike Sherov Avatar answered Sep 28 '22 02:09

Mike Sherov


You could use regular expressions ..

for example in Dreamweaver on the search dialog box :

  1. select 'Find in: Entire current local site.."
  2. select 'Search: Source code'
  3. check 'Use regular expression'
  4. in the find textarea type class\s*?=\s*?".*?content.*?"
  5. click 'find all'

the same regular expression could be used with other software that can search inside files using regular expressions....
for example : http://www.sowsoft.com/search.htm (not affiliated with them, just found it for here..)

Keep in mind though, that all the suggestions here do not take into account the case where the class is added by script..

like image 26
Gabriele Petrioli Avatar answered Sep 28 '22 04:09

Gabriele Petrioli