7

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.

7
  • 3
    Why would you do that? Word isn't meant for that. It tries to do it (HTML mail anyone) and fails miserably.
    – PeeHaa
    May 18, 2012 at 15:30
  • MS Word is a definite no no for making html. Use a free program like notepad++
    – Sam
    May 18, 2012 at 15:34
  • Word will assign classes to styles. If you are trying to create a formatted Word document using HTML, this may help.
    – Remou
    May 18, 2012 at 15:36
  • Remou: so if there is a style in Word that has a class name that matches it should apply the style? This is hugely helpful if that's gonna work!
    – Geekster
    May 18, 2012 at 15:41
  • If you want a document containing HTML, use a PDF. May 18, 2012 at 15:42

5 Answers 5

3

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 style="border:1px solid #CCC;font-size:1.5em">Title</h1>
2

What 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.

1

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.

0
0

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .