Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a sample:

<html>
<head>
    <title>word test</title>
</head>
<body>
    <div style='position: absolute; width: 30px; height: 50px; top: 100px; left: 20px; border-color: black; border-width: 1px; border-style: solid;'>
        <p>Hello!</p>
    </div>
</body>
</html>

Save it as "word.doc" and open in MS WORD.

Absolute position don't work!

Div is rendered on the top of document and with 100% width. Why? I can't use a html tables.

Version on ms word: 2003

share|improve this question

migrated from stackoverflow.com May 28 '10 at 18:47

This question came from our site for professional and enthusiast programmers.

    
Office 2007 - burden of my life (especially Outlook 2k7!) –  Neurofluxation May 27 '10 at 9:11
1  
Why are you using HTML to generate a Word document? Office and HTML are like fire and ice. –  RoToRa May 27 '10 at 9:48

3 Answers 3

You can find a full list of Word 2007's supported CSS here:

http://msdn.microsoft.com/en-us/library/aa338201%28office.12%29.aspx

Yes, it's shockingly poor but would you expect anything else from Microsoft's Office team?

Here's a quick reference list of CSS2 that you can't use:

  • azimuth
  • background-attachment
  • background-image
  • background-position
  • background-repeat
  • border-spacing
  • bottom
  • caption-side
  • clear
  • clip
  • content
  • counter-increment
  • counter-reset
  • cue-before, cue-after, cue
  • cursor
  • display
  • elevation
  • empty-cells
  • float
  • font-size-adjust
  • font-stretch
  • left
  • line-break
  • list-style-image
  • list-style-position
  • marker-offset
  • max-height
  • max-width
  • min-height
  • min-width
  • orphans
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • overflow-x
  • overflow-y
  • pause-before, pause-after, pause
  • pitch
  • pitch-range
  • play-during
  • position
  • quotes
  • richness
  • right
  • speak
  • speak-header
  • speak-numeral
  • speak-punctuation
  • speech-rate
  • stress
  • table-layout
  • text-shadow
  • text-transform
  • top
  • unicode-bidi
  • visibility
  • voice-family
  • volume
  • widows
  • word-spacing
  • z-index
share|improve this answer
    
Very nice. Never knew this existed. –  zfus Aug 6 '13 at 16:32

Probably because Microsoft Word uses its own renderer which sucks.

An article from 2007 says...

No support for float or position

(this should apply to you because your version is 2003)

So you are out of luck. Unfortunately, table based layouts are still common in HTML emails because of this reason.

share|improve this answer
    
Ok. I have collection of blocks. I know x, y, width, height of each block. Can I convert it to table design? Blocks don't has children. –  Tim May 27 '10 at 9:13

Ok, I had the same problem. What I did is to format my html document in word and saved it. Then I striped down the markup to what I actually really needed. You need to include the vml namespace to your html doc (xmlns:v="urn:schemas-microsoft-com:vml")

<html xmlns:v="urn:schemas-microsoft-com:vml">

Then you need the following code, choose the id how ever you want, you can also choose the position of the image more or less free. The image is in front of the text.

<!--[if gte vml 1]><v:shape id="Bild_x0020_1" type="#_x0000_t75"
style='position:absolute;left:0;text-align:left;margin-left:338.55pt;
margin-top:26pt;width:105pt;height:138.75pt;z-index:251658240;'>
<v:imagedata src="http://c7.valuewalk.com/wp-content/uploads/2011/12/billg4_web1.jpg"/>
</v:shape><![endif]-->

Although I'm not sure if this works for Word 2003, my Version is 2010.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.