Chimons
Chimons

Reputation: 115

Use <style> tag in TinyMCE

I'm trying to add css in a <style> tag in a TinyMCE editor but when I validate the HTML changes, TinyMCE automatically put my css between comments.

Exemple :

If I type

<style>
h3{
   font-size:50px;
}
</style>
<h3>Hello</h3>

TinyMCE transforms that in :

<style>
h3{<!--
   font-size:50px;-->
}
</style>
<h3>Hello</h3>

In the setup I set :

extended_valid_elements: "pre[*],script[*],style[*]",
valid_children: \'+body[style|script],pre[script|div|p|br|span|img|style|h1|h2|h3|h4|h5],*[*]\',
valid_elements : \'*[*]\',

Am I doing something wrong ?

Upvotes: 1

Views: 3724

Answers (2)

Erik van Velzen
Erik van Velzen

Reputation: 7062

If you put tinyMCE in fullpage mode, you can put styles in the <head>. It will not put the comment node there.

<script type="text/javascript">
tinyMCE.init({
        plugins : "fullpage",
});
</script>

Upvotes: 2

chiliNUT
chiliNUT

Reputation: 19592

The last poster on this thread (http://www.tinymce.com/forum/viewtopic.php?id=25443) writes:

TinyMCE produces XHTML and we wrap the style contents in a comment to keep any XML parser from failing to parse the contents all browsers support the comment syntax. --Spocke

so the answer is that no, this cannot be changed, because tiny mce not only is sworn to generate valid HTML, but must also generate valid (ughh) XHTML. Since they say all browsers support the comment syntax then it shouldn't really be a problem for you.

Upvotes: 1

Related Questions