Why does my style-tag disappear, in both my free site and my localhost site? Where do I find the Wordpress guidelines that specify what can-not be done.

Example, where do I find: "Wordpress does not support the internal-style sheets and "style tag" in posts/pages, and it will be deleted from your post/page on the free hosted sites."?

  • Inline style tags/sheets aren't generally forbidden, if you're getting at that. Though it isn't recommended to use them extensively - or at all. Summarized, if you want concrete help, then you have to show and actually explain what you are doing. Mar 28, 2015 at 14:37
  • I create a new post, paste the following into the text tab, then switch to visual, then back to text. The HTML is gone just leaving "hello". <style type="text/css" media="all"> p { font: 1em Times serif; color: #c00; } h1 { font: 2em Times serif; color: #f00; } </style> hello
    – apergiel
    Mar 28, 2015 at 17:39
  • Same thing with pages. HTML dissappears when switching from text to visual to text.
    – apergiel
    Mar 28, 2015 at 17:43
  • You have to extend $allowedposttags, e.g. via ìnit hook. And via tiny_mce_before_init hook you have to make sure it is part of the inputed arrays extended_valid_elements element. Not going to show you how, because I think it is bad - very. Mar 28, 2015 at 19:17

1 Answer 1


WordPress does remove style tags. While it allows HTML to some degree in post content, it's not really meant for full range of it. It's a content, not markup data.

You could use tiny_mce_before_init filter to adjust extended_valid_elements for TinyMCE instance.

See this answer on SO for some examples.

  • Ok. I'm not going to use internal style sheets. Should not the WP HTML stripper that is used in the Visual/Text Editor leave a comment behind after stripping out my well-thought-out CSS code, something like: <!-- Your CSS code as follows has been stripped out, because WP doenst like it. Your unliked code follows in this comment....Have the nicest of days.-->
    – apergiel
    Mar 28, 2015 at 22:21
  • Thank you Rarst, As a newbie, I have learned that its not Wordpress per se that is at issue. It is the TinyMCE wysiwyg online editor that Wordpress uses.
    – apergiel
    Mar 29, 2015 at 15:47

Your Answer

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

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