cmcginty
cmcginty

Reputation: 117018

Valid workaround for <style> tags inside of <body> to add custom CSS?

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?

Upvotes: 2

Views: 1223

Answers (2)

Andy E
Andy E

Reputation: 344575

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>

Upvotes: 0

Mitch Dempsey
Mitch Dempsey

Reputation: 39889

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

Upvotes: 3

Related Questions