Ce site disposera de fonctionnalités limitées pendant que nous effectuons des opérations de maintenance en vue de vous proposer un meilleur service. Si un article ne règle pas votre problème et que vous souhaitez poser une question, notre communauté d’assistance est prête à vous répondre via @FirefoxSupport sur Twitter, et /r/firefox sur Reddit.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

When I copy a text from MS Word and paste it into my HTML page in Firefox, it brings over too many style definitions. Can that be avoided?

  • 7 réponses
  • 10 ont ce problème
  • 75 vues
  • Dernière réponse par msameer

more options

Basically I have an HTML with DIV tag and having contentEditable set to true. Whenever I copy content from MS Word and paste it in this html, it brings over tons of styles and messes up the whole content. Same set of actions work fine on same HTML in IE !

Basically I have an HTML with DIV tag and having contentEditable set to true. Whenever I copy content from MS Word and paste it in this html, it brings over tons of styles and messes up the whole content. Same set of actions work fine on same HTML in IE !

Solution choisie

There is an online tool at


      http://demo.typps.com/Editor/mswordcleanup.aspx
      and 
      http://www.textism.com/wordcleaner/ 
       (for 20kb docs or less)

that will strip Word's proprietary tags from an HTML document.

You might find the following article to be informative:


      http://gabesumner.com/copy-from-ms-word-paste-into-a-rich-text-wysiwyg-editor

You can always use the SeaMonkey Composer editor instead of Word. See:


      http://www.seamonkey-project.org/

SeaMonkey is a Mozilla project built from Firefox.


edited to add textism

Lire cette réponse dans son contexte 👍 1

Toutes les réponses (7)

more options

One solution -- don't do that.

Microsoft wrote both IE and MS Word, IE will be looking at the same code generated.

So what do you mean that you get too many styles, is that an error message, or you just don't like the generated code, or that the generated code does not work.

more options

I don't get any errors and generated code works. But the generated code overcomplicates the basic styles. E.g. I used bold feature on a word called "Hello" and and I get 50 styles added in the div field after copy-paste. Whereas in case of IE I get a clean tag around the same word "Hello". So this operation is more clean and intelligent in case of IE but in case of Firefox it just puts so much data that my field widths are on the brink of overflow!

more options

Would you supply the application, content, url descriptions as well as you can for each, and exactly what you are doing.

1) source where "Hello" is being brought from
2) target where you are pasting into with Firefox
3) and with IE
4) where you see the source directly in what you paste or by viewing source

Is this a WYSIWYG editor where what you normally see is what it is going to look like when finished.

A simple change or difference in fonts font-size could make a big difference in what is happening.

Modifié le par David McRitchie

more options

Sure. I can. How do I attach it here? There is one sample HTML file and then i can send a sample Word document with a bold "Hello" text just to illustrate the issue.

more options

Extra code is one of the pitfalls of using WYSIWYG cutting and pasting, and using styling in general.

So while it may be interesting to try to reduce the amount of code, there probably won't be any direct approach without extra steps to get you what you want with bare bones code that appears as you want it to or at least acceptable.

I guess you might have to take a screen image, clip the relevant portion, since you can only attach an image file here not a text file.

Posting a screen shot

more options

Solution choisie

There is an online tool at


      http://demo.typps.com/Editor/mswordcleanup.aspx
      and 
      http://www.textism.com/wordcleaner/ 
       (for 20kb docs or less)

that will strip Word's proprietary tags from an HTML document.

You might find the following article to be informative:


      http://gabesumner.com/copy-from-ms-word-paste-into-a-rich-text-wysiwyg-editor

You can always use the SeaMonkey Composer editor instead of Word. See:


      http://www.seamonkey-project.org/

SeaMonkey is a Mozilla project built from Firefox.


edited to add textism

Modifié le par sctl

more options

Thanks folks for your help. Reply from #sctl was helpful in finding a tool for cleaning up the "garbage" ms word introduces.