Forum How do I...?

use style elements inside the body element

jehiah
I know it isn't valid html to have a style elements under the body element, but is there a way to get that to work? Below is a snippet of code to illustrate what i'm talking about. Prince by default will not apply the style for blue.

<html>
<head>
<style>
.red{color:#f00;}
</style>
</head>
<body>
<style>
.blue{color:#00f;}
</style>
<p>with <span class="red">red</span> and <span
class="blue">blue</span> text</p>
</body>
</html>
mikeday
I'm afraid that this will not work; the XHTML <style> element can only ever appear in the <head>, and Prince will ignore it anywhere else.

One possible solution that you might like to try is the style attribute, which would allow you to write your example like this:

<html>
<head>
<style>
.red{color:#f00;}
</style>
</head>
<body>
<p>with <span class="red">red</span> and <span
style="color: #00f">blue</span> text</p>
</body>
</html>

Otherwise all declarations have to go in the head of the document or in linked style sheets.