views:

32

answers:

2

I know putting <style> tags inside of <body> is not valid. What other techniques are possible to get around this limitation?

In my design I have a few static pages created with server side includes. For each page I need a few extra lines of CSS to control the display of a few DIVs.

What is the best valid way to achieve this effect?

+1  A: 

You can use javascript inside <script> tags that insert a css <link> element into the page that should then load the associated stylesheet

webdestroya
Users with JavaScript disabled would be adversely affected by a JS-only solution.
Andy E
@Andy E - Correct, but you can't always support everyone.
webdestroya
This was a good solution, however I ended up splitting my server-side include files so I could put custom values in the <head> element of every page.
Casey
A: 

If it's just a few DIVs and just a few styles, use the style attribute. Sure, it's not ideal, but it's valid.

<div style="position: relative; width:200px; height:100px;">etc...</div>
Andy E
The div's are inside of my static includes, but depending on the page that is using the include, I want to make the CSS style dynamic.
Casey