I'm have a tough time getting my HTML that I am pasting into word to be converted to the proper styles I want.
My HTML includes: dt, dd, h1-h7, p, li, ul... etc.
dt and dd are not working. Word thinks they are paragraphs and applies the "Normal" style to them.
h1-h7 work great.
li works great.
What can I put into word so that when I paste in these dt & dd they will select a proper style?
EDIT: I certainly appreciate the responses received so far, however nobody has really answered this yet. I cannot decide what the export medium is for this job, as I am not the decision maker. The requirement is MS Word files. There will be headers and footers, page numbering and a table of contents to the project, but whenever I paste HTML into Word the same problem happens: certain tags are styled and others are ignored.
My guess is that this is a deficiency/bug in MS Word, so I will go ahead and open a ticket with Microsoft.
75 Answers
I have found a suitable answer to this.
- By stylizing each HTML object in the source, Word will then apply styles if you "paste" with the option "Keep source formatting", most of the kinds of CSS will be converted into a Word style.
eg:
This will have the same formatting in HTML when you copy/paste to Word with "Keep Formatting" selected.
<h1>Title</h1> Unfortunately Word has issues with many different HTML/CSS tags, so I'm afraid it's a case of trial and error. When it comes to dt and dd you could replicate the formatting you want by using CSS classes and then applying them to suitable HTML alternatives.
One good tip is that Word has big difficulties with different style sections (especially when it comes to mail.) So always only have only <style></style> section if you're using classes.
Word has difficulties with formatting on pasted html. I've had success with color, background-color, margin and page-break-before:always (avoid padding except on td elements and avoid page-break-after). Also font, font-size, font-weight and tables work well. It can see general css style rules which are not just embedded as a style attribute directly on the element. Try to simplify your source html as much as possible.
What finally worked for me is to simply paste the HTML into a text editor, save it as plain text (with an appropriate filename extension), and then open that file in Word.
As for the missing style rendering, you may find some joy in working with the "lost styles" on the HTML side, or using the style definitions on the Word side. If you have to do this as a recurring text, maybe you can devise a style definition in Word that would render your .dt and .dd as you wish, and then save the document as a template that you can use for future operations.
I wish I knew more about working with Word styles, but you might have some insight that makes that an easy operation.
0What I do is: paste the HTML into a text editor, save it as plain text in a file with extension name .html, and then open that file in any browser and copy the page or parts of it from the browser to Word.