Sent by Ian Hickson on 12 November 2002 17:05
On Mon, 11 Nov 2002, Jon Plummer wrote:
>
> I spent far too long at work today trying to add some external CSS to a
> page after the fact, i.e. while rendering the <body>, and I'm looking
> for alternative ways to do so AND have my XHTML validate. Y'see, I'm
> working on a project where I need to add page-specific styles (for
> widgets and whatnot), but won't know I need to add them until well
> after the <head> tag is closed.
There are three ways that I can think of.
1. Always include all the styles, and just let your page markup determine
(through the use of carefully written selectors) which styles will apply.
2. Buffer the <body> in your script, and, once you know what you are going
to want to output, print the <head> with the custom styles, then the
buffered <body>.
3. Make the <head> point to a stylesheet generated by a script with a
unique ID. Make this script wait for the first script to have finished
generating the body, and then take information passed from the first
script to the second to generate the stylesheet.
Option 1 is the theoretical solution; Option 2 is the quick hack solution;
Option 3 is the masterful hack which guarentees you job security.
HTH,
--
Ian Hickson )\._.,--....,'``. fL
"meow" /, _.. \ _\ ;`._ ,.
http://index.hixie.ch/ `._.-(,_..'--(,_..'`-.;.'
_______________________________________________
css-discuss [EMAIL-REMOVED]]
http://two.pairlist.net/mailman/listinfo/css-discuss
Sponsored by www.westciv.com - CSS resources | software | learning