Tool to group STYLE tags together?

J

John Dalberg

I am using an application that dynamically creates style tags all over the
place in the html file. I mean some inside the head section and some in the
body section. I have no control over this.

Is there a tool/utility out there which reads in such a file, moves all the
STYLE tags and groups them together in the head section or an external
file? (Just grouping them is fine with me)

John Dalberg
 
A

Adrienne Boswell

John Dalberg wote:
I am using an application that dynamically creates style tags all over the
place in the html file. I mean some inside the head section and some in the
body section. I have no control over this.

Is there a tool/utility out there which reads in such a file, moves all the
STYLE tags and groups them together in the head section or an external
file? (Just grouping them is fine with me)

John Dalberg

If you have a program that uses HTML-Tidy, like HTML-Kit
<http://www.chami.com/html-kit/> you can clean it up that way.
Personally, I prefer TopStyle <http://www.bradsoft.com/top-style/>. If
also has a means to clean up external stylesheets and get everything
ordered.
 
N

Nico Schuyt

John said:
I am using an application that dynamically creates style tags all
over the place in the html file.

What is that application? Do you have an URL for the files?
I mean some inside the head section
and some in the body section. I have no control over this.
Is there a tool/utility out there which reads in such a file, moves
all the STYLE tags and groups them together in the head section or an
external file? (Just grouping them is fine with me)

I cann't imagine there is such a tool. Maybe a search&replace can replace
the inline styles with classes.
 
T

Toby Inkster

John said:
I am using an application that dynamically creates style tags all over
the place in the html file. I mean some inside the head section and some
in the body section. I have no control over this.

Do you mean style *elements* or style *attributes*? Style *elements* look
something like this:

<style type="text/css">
...
</style>

whereas style attributes look like this:

style="..."

It really helps if you use the correct terminology, as the answers may be
different for each interpretation.

In the case of <style> elements, it should be relatively easy to
post-process the page (using e.g. regular expressions in PHP) to merge
pull out the CSS from several style blocks and concatenate them into one.

In the case of style attributes on other elements, things get a bit more
tricky. It could also be done with a bit of scripting, but would require
more work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top