What do <o:p> elements do anyway?
Asked Answered
D

1

112

I've been running into some (standard) issues with Microsoft Office injecting its nasty markup into some html after forwarding an email via Outlook.

I'm interested to know:

  • Is there a resource that explains what <o:p> elements actually do
  • What other MSO elements are commonly injected
Dellora answered 18/10, 2011 at 14:32 Comment(3)
If you're after cleaning the mess, check this blog post by Jeff: codinghorror.com/blog/2006/01/cleaning-words-nasty-html.htmlHorseleech
I upvoted, we can't know who downvoted, sorry. Slight change it's @leonbloy (he removed a tag) but I doubt it.Horseleech
That post still seems to be around, but at a different site: blog.codinghorror.com/cleaning-words-nasty-htmlPerla
H
132

Couldn't find any official documentation (no surprise there) but according to this interesting article, those elements are injected in order to enable Word to convert the HTML back to fully compatible Word document, with everything preserved.

The relevant paragraph:

Microsoft added the special tags to Word's HTML with an eye toward backward compatibility. Microsoft wanted you to be able to save files in HTML complete with all of the tracking, comments, formatting, and other special Word features found in traditional DOC files. If you save a file in HTML and then reload it in Word, theoretically you don't loose anything at all.

This makes lots of sense.

For your specific question.. the o in the <o:p> means "Office namespace" so anything following the o: in a tag means "I'm part of Office namespace" - in case of <o:p> it just means paragraph, the equivalent of the ordinary <p> tag.

I assume that every HTML tag has its Office "equivalent" and they have more.

Horseleech answered 18/10, 2011 at 15:3 Comment(2)
This is interesting. I just ran into this when posting a blog. Thanks for the info.Earing
This appears to have changed. Word 365 does not generate markup like <o:p> when saving a document in HTML format. Presumably, the bulky code that it generates in the head element serves the same purpose in a different way.Hellebore

© 2022 - 2024 — McMap. All rights reserved.