I have added TinyMCE to work with one of my text formats, and I added the different alignment buttons. When I try to center some text it adds "text-align: center" to the p... but when I save it, it goes back to normal. I would like to fix that to be able to align text and images. I installed a module called WYSIWYG Filter and added "text-align" in Text properties... still doesn't work. I also added "p[style|text-align]" to the "HTML elements and attributes" section... still doesn't work.

Any ideas of what could I be missing? ...I'm using Drupal 7 BTW

1 Answer 1


If you're using the filtered HTML input format, that would be stripping it out.

If not, it sounds like your markup is weird. The way you describe it, what might work if it read <p align="center"> (not that I recommend this) reads <p style="text-align:center">. I think WYSWIG editors tend to prefer classes to putting styles right in the markup, so I'd do something like <p class="centered-text"> and add .centered-text{ text-align:center } to your stylesheet.

I would double-check your site with a DOM inspector to make sure your style on your <p> isn't being overridden by a stylesheet. If nothing else works, you could use a different editor. jWYSIWYG, openWYSIWYG, Whizzywig, and nicEditor use align="wherever" instead of style="text-align:wherever" which might work (again, I don't recommend this, but it's a potential short-term solution. For reference, MarkItUp and WYMeditor don't offer alignment buttons, and CKEditor, FCKEditor, TinyMCE, and YUIeditor do it the "right" way, using style="")

  • thanks for your answer, but how do I change the default behavior of adding style="text-align:center" to adding class="centered-text"
    – la_f0ka
    Aug 11, 2012 at 13:39
  • added info about which wysiwyg editors have different default behavior, although none of the ones i've tried so far add a class.
    – beth
    Aug 11, 2012 at 20:09
  • Wait, are you using a separate TinyMCE module as well as the WYSIWYG module, or are you just using WYSIWYG with the TinyMCE library in sites/all/libraries/tinymce? My answer is based on using WYSIWYG with the respective editor libraries installed in the libraries file. Try doing it that way and see if that works better, maybe?
    – beth
    Aug 11, 2012 at 20:17
  • OK, I eventually got it to work... it still does the "tinymce way" with styles instead of classes within the tags... I'm using the WYSIWYG Filter module to allow all the tags and attributes I need available... far from perfect, ugly as hell,.. but it works
    – la_f0ka
    Aug 12, 2012 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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