Currently working on a project here http://palanquin.shrimp-works.com. When I try to validate what I have done so far, using http://validator.w3.org/, I get lots of this error Element style not allowed as child of element div in this context. (Suppressing further errors from this subtree.), which basically means there is a div which is printing it's styles to the body tag of my document. This means simple styles like background color, text color, etc are all being printed in the body tag of the html, ruining any chance of html5 validation.

Is there a wordpress filter that can print all style tags from the text editor or tinymce to the head instead of to the body? I know how to enqueue inline styles in functions.php. I don't think that's what I need here. Any ideas?

1 Answer 1


The content you input via editor is saved as such, there would be no straightforward way to untangle styles from it and output it in the head of the page. Doable, but far form convenient.

You might want to look into adding extra input for such elements to post editor, save data in custom field, and read/output it from there (likely at wp_print_styles hook).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.